The difficulty with this is that the parser would need to accept two
distinct wire types for each integer field. The parsing code would become:

if tag number is x:
  if wire type is positive varint { ... }
  if wire type is negative varint { ... }

This leads to larger code size and has potential performance impact. I'm
not sure if experiments were ever done with this sort of approach - the
penalties may not be too bad - for packed repeated fields, a change was
made to allow the parser to accept either the packed or unpacked format,
and this was acceptable. However, the impact may be greater for singular
integer fields, which tend to be more prevalent, at least within Google. In
any event, changes to the wire format are very infrequent (note that the
zigzag encoding didn't actually change the wire format, just how the varint
wire type was interpreted); there'd have to be a pretty significant impact
in wire size to make this sort of change at this point.

On Fri, Dec 2, 2011 at 8:04 PM, Paul TOTH <[email protected]> wrote:

> Protocol Buffers is great, but there's something I don't understand.
>
> VarInt is great to store positive integers
> sint32/64 are stored as "zigzag" VarInt
>
> why int32/64 aren't stored as :
>  1) VarInt when positive (type 0)
>  2) NegativeVarIn when negative (a new type 6 that store the opposite
> value as a positive VarInt)
>
> Then you don't need to specify sint32/64 in the Message and integers
> will be stored in the most efficient way each time, regardless of they
> sign.
>
> Regards from France
> Paul TOTH
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to