by ridiculous_fish · 8y ago · 0 comments
1. `shift` can grow large, and an overlong left shift will panic in Rust. I expect an input like "gggggggC" to crash.
2. `accum >>= 1` is wrong because it rounds down. It needs to be a round-towards-zero: `accum /= 2`.
3. `accum` is a 32 bit int which is too small. It needs to be larger so it can represent -2^31 in sign-magnitude form.
We've already fixed some of these issues[0] but I didn't update the code snippets in the article -- woops!
[0] https://github.com/tromey/vlq/commit/3b41a2b6c778ce476eaaa28...