Commit ab1d6229 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Sebastien Robin

Delay StringIO creation until actually needed.

parent 10c717d3
...@@ -55,14 +55,14 @@ class BTreeData(Persistent): ...@@ -55,14 +55,14 @@ class BTreeData(Persistent):
def read(self, offset, size): def read(self, offset, size):
start_offset = offset start_offset = offset
tree = self.tree tree = self.tree
result = StringIO()
write = result.write
try: try:
key = tree.maxKey(offset) key = tree.maxKey(offset)
except ValueError: except ValueError:
return '' return ''
else: else:
offset -= key offset -= key
result = StringIO()
write = result.write
written = 0 written = 0
for key in tree.iterkeys(key): for key in tree.iterkeys(key):
padding = min(size, key - start_offset - written) padding = min(size, key - start_offset - written)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment