aboutsummaryrefslogtreecommitdiff
path: root/python/google
diff options
context:
space:
mode:
authortemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-07-27 18:38:54 +0000
committertemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-07-27 18:38:54 +0000
commit24856db0e9c6a8c5d0866fae1eee31a6fbc374b2 (patch)
tree913ed270b4dfe655862d0a0e91e5292316c11824 /python/google
parent6fdb0964e3a9873d1eb08b28634c74bd082326ac (diff)
downloadprotobuf-24856db0e9c6a8c5d0866fae1eee31a6fbc374b2.tar.gz
protobuf-24856db0e9c6a8c5d0866fae1eee31a6fbc374b2.tar.bz2
protobuf-24856db0e9c6a8c5d0866fae1eee31a6fbc374b2.zip
Applied Ulrich Kunitz's patches to slightly optimize Python serialization code.
Diffstat (limited to 'python/google')
-rwxr-xr-xpython/google/protobuf/internal/output_stream.py5
-rwxr-xr-xpython/google/protobuf/internal/wire_format.py2
2 files changed, 3 insertions, 4 deletions
diff --git a/python/google/protobuf/internal/output_stream.py b/python/google/protobuf/internal/output_stream.py
index 767e9725..ccb91225 100755
--- a/python/google/protobuf/internal/output_stream.py
+++ b/python/google/protobuf/internal/output_stream.py
@@ -101,11 +101,10 @@ class OutputStream(object):
while True:
bits = unsigned_value & 0x7f
unsigned_value >>= 7
- if unsigned_value:
- bits |= 0x80
- self._buffer.append(bits)
if not unsigned_value:
+ self._buffer.append(bits)
break
+ self._buffer.append(0x80|bits)
def ToString(self):
"""Returns a string containing the bytes in our internal buffer."""
diff --git a/python/google/protobuf/internal/wire_format.py b/python/google/protobuf/internal/wire_format.py
index 69aa4abf..ea219e27 100755
--- a/python/google/protobuf/internal/wire_format.py
+++ b/python/google/protobuf/internal/wire_format.py
@@ -87,7 +87,7 @@ def ZigZagEncode(value):
"""
if value >= 0:
return value << 1
- return ((value << 1) ^ (~0)) | 0x1
+ return (value << 1) ^ (~0)
def ZigZagDecode(value):