Skip to content
Snippets Groups Projects
Commit fc8da050 authored by raila's avatar raila
Browse files

Applied Ulrich Kunitz's patches to slightly optimize Python serialization code.

parent 7747a070
No related branches found
No related tags found
No related merge requests found
...@@ -36,3 +36,5 @@ Maven packaging: ...@@ -36,3 +36,5 @@ Maven packaging:
Non-Google patch contributors: Non-Google patch contributors:
Kevin Ko <kevin.s.ko@gmail.com> Kevin Ko <kevin.s.ko@gmail.com>
Johan Euphrosine <proppy@aminche.com>
Ulrich Kunitz <kune@deine-taler.de>
...@@ -101,11 +101,10 @@ class OutputStream(object): ...@@ -101,11 +101,10 @@ class OutputStream(object):
while True: while True:
bits = unsigned_value & 0x7f bits = unsigned_value & 0x7f
unsigned_value >>= 7 unsigned_value >>= 7
if unsigned_value:
bits |= 0x80
self._buffer.append(bits)
if not unsigned_value: if not unsigned_value:
self._buffer.append(bits)
break break
self._buffer.append(0x80|bits)
def ToString(self): def ToString(self):
"""Returns a string containing the bytes in our internal buffer.""" """Returns a string containing the bytes in our internal buffer."""
......
...@@ -87,7 +87,7 @@ def ZigZagEncode(value): ...@@ -87,7 +87,7 @@ def ZigZagEncode(value):
""" """
if value >= 0: if value >= 0:
return value << 1 return value << 1
return ((value << 1) ^ (~0)) | 0x1 return (value << 1) ^ (~0)
def ZigZagDecode(value): def ZigZagDecode(value):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment