summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-01-20 14:54:25 +1100
committerMichael Cahill <michael.cahill@mongodb.com>2016-01-20 14:54:25 +1100
commit0c241d2988705a7b77ee23410f1ac032767ae791 (patch)
tree2b2d2a503685fbbb5f5363b7627b35a91537848e /lang
parentb7f10136bb4baf8d72194ac573bf6a2009577b62 (diff)
downloadmongo-0c241d2988705a7b77ee23410f1ac032767ae791.tar.gz
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.
Diffstat (limited to 'lang')
-rw-r--r--lang/python/wiredtiger/packing.py16
1 files changed, 4 insertions, 12 deletions
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':