BrendanBenshoof / StackStream

Bytecode Assembly language for arbitrary length bytestrings
7 stars 1 forks source link

Why not a varint? #2

Open jbenet opened 9 years ago

jbenet commented 9 years ago

For the length?

BrendanBenshoof commented 9 years ago

Assuming you mean: https://developers.google.com/protocol-buffers/docs/encoding#varints

thanks for pointing that out. It looks like it might be better. It costs 1 bit per 7 bits in length versus my current idea that costs 1 byte per 1 byte of length.

I'm sold on this idea, and it makes things more efficent.

Why does the spec I referenced reverse the order of the 7-bit chunks? I don't see a benefit to that.

jbenet commented 9 years ago

Assuming you mean: https://developers.google.com/protocol-buffers/docs/encoding#varints

there's many styles of varints, but yeah, that works.

Why does the spec I referenced reverse the order of the 7-bit chunks? I don't see a benefit to that.

not sure, convention maybe? https://en.wikipedia.org/wiki/Variable-length_quantity

jbenet commented 9 years ago

(i usually do varints without reversing)