diff options
author | Rafael H. Schloming <rhs@apache.org> | 2011-03-08 16:54:50 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2011-03-08 16:54:50 +0000 |
commit | 73f6c7a646e567507b05a9809c95d0bc3f7fbebe (patch) | |
tree | cc2e47d6979a78967c611dcdf873cda5f58b3cee /python | |
parent | 52ba27a840a75a7afc2d4cae4fe5152e84e8f3b0 (diff) | |
download | qpid-python-73f6c7a646e567507b05a9809c95d0bc3f7fbebe.tar.gz |
QPID-3130: applied patch for codec performance
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1079434 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python')
-rw-r--r-- | python/qpid/codec010.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/python/qpid/codec010.py b/python/qpid/codec010.py index 0846db6bf7..94a1cd4263 100644 --- a/python/qpid/codec010.py +++ b/python/qpid/codec010.py @@ -17,7 +17,7 @@ # under the License. # -import datetime +import datetime, string from packer import Packer from datatypes import serial, timestamp, RangedSet, Struct, UUID from ops import Compound, PRIMITIVE, COMPOUND @@ -241,15 +241,20 @@ class Codec(Packer): v = sc.read_primitive(type) result[k] = v return result + + def _write_map_elem(self, k, v): + type = self.encoding(v) + sc = StringCodec() + sc.write_str8(k) + sc.write_uint8(type.CODE) + sc.write_primitive(type, v) + return sc.encoded + def write_map(self, m): sc = StringCodec() if m is not None: sc.write_uint32(len(m)) - for k, v in m.items(): - type = self.encoding(v) - sc.write_str8(k) - sc.write_uint8(type.CODE) - sc.write_primitive(type, v) + sc.write(string.joinfields(map(self._write_map_elem, m.keys(), m.values()), "")) self.write_vbin32(sc.encoded) def read_array(self): |