Closed MartinNowak closed 9 years ago
According to the encoding page, it's POSSIBLE to encode a signed long or signed int with varint directly, just not recommended...
Sure, but you have to cast it to an unsigned value so that the bit shifting works. Previously negative values would lead to an infinite loop because the sign bit isn't shifted.
Ping, I added a test for (-1).toVarint
just to emphasize, that it works with negative numbers.
Previously this test would hang.
Alright, I'll have a chance to look at it in a day or so... Basically whenever I get power back. Yay snowstorms.
src > 0x7F
is faster thansrc & ~0x7FUL
because the instruction can be encoded with fewer bytes (small constant)