From 0c241d2988705a7b77ee23410f1ac032767ae791 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Wed, 20 Jan 2016 14:54:25 +1100 Subject: WT-1517 Set the packing size = 1 by default in the fast path. Don't add extra checks into regular processing: we already set size = 1 in normal processing of packing strings if no size is specified. Make the Python packing code match so all test cases pass. --- lang/python/wiredtiger/packing.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'lang') diff --git a/lang/python/wiredtiger/packing.py b/lang/python/wiredtiger/packing.py index 2012263e258..5d21b539888 100644 --- a/lang/python/wiredtiger/packing.py +++ b/lang/python/wiredtiger/packing.py @@ -70,6 +70,8 @@ def __unpack_iter_fmt(fmt): size = (size * 10) + int(char) havesize = 1 else: + if not havesize: + size = 1 yield offset, havesize, size, char size = 0 havesize = 0 @@ -83,14 +85,12 @@ def unpack(fmt, s): result = [] for offset, havesize, size, f in __unpack_iter_fmt(fmt): if f == 'x': - if not havesize: - size = 1 s = s[size:] # Note: no value, don't increment i elif f in 'SsUu': if not havesize: if f == 's': - size = 1 + pass elif f == 'S': size = s.find('\0') elif f == 'u' and offset == len(fmt) - 1: @@ -106,14 +106,10 @@ def unpack(fmt, s): s = s[size:] elif f in 't': # bit type, size is number of bits - if not havesize: - size = 1 result.append(ord(s[0:1])) s = s[1:] elif f in 'Bb': # byte type - if not havesize: - size = 1 for i in xrange(size): v = ord(s[0:1]) if f != 'B': @@ -122,8 +118,6 @@ def unpack(fmt, s): s = s[1:] else: # integral type - if not havesize: - size = 1 for j in xrange(size): v, s = unpack_int(s) result.append(v) @@ -164,11 +158,9 @@ def pack(fmt, *values): l = val.find('\0') else: l = len(val) - if havesize: + if havesize or f == 's': if l > size: l = size - elif f == 's': - havesize = size = 1 elif (f == 'u' and offset != len(fmt) - 1) or f == 'U': result += pack_int(l) if type(val) is unicode and f in 'Ss': -- cgit v1.2.1