Commit 0dc21436 authored by Dmitry Vasiliev's avatar Dmitry Vasiliev

Optimizations

parent ffe4bb02
...@@ -1801,9 +1801,12 @@ class FileIterator(Iterator, FileStorageFormatter): ...@@ -1801,9 +1801,12 @@ class FileIterator(Iterator, FileStorageFormatter):
def _skip_to_start(self, start): def _skip_to_start(self, start):
# Scan through the transaction records doing almost no sanity # Scan through the transaction records doing almost no sanity
# checks. # checks.
file = self._file
read = file.read
seek = file.seek
while 1: while 1:
self._file.seek(self._pos) seek(self._pos)
h = self._file.read(16) h = read(16)
if len(h) < 16: if len(h) < 16:
return return
tid, stl = unpack(">8s8s", h) tid, stl = unpack(">8s8s", h)
...@@ -1816,13 +1819,12 @@ class FileIterator(Iterator, FileStorageFormatter): ...@@ -1816,13 +1819,12 @@ class FileIterator(Iterator, FileStorageFormatter):
self._pos = long(self._pos) + tl + 8 self._pos = long(self._pos) + tl + 8
if __debug__: if __debug__:
# Sanity check # Sanity check
self._file.seek(self._pos - 8, 0) seek(self._pos - 8, 0)
rtl = self._file.read(8) rtl = read(8)
if rtl != stl: if rtl != stl:
pos = self._file.tell() - 8 pos = file.tell() - 8
panic("%s has inconsistent transaction length at %s " panic("%s has inconsistent transaction length at %s "
"(%s != %s)", "(%s != %s)", file.name, pos, u64(rtl), u64(stl))
self._file.name, pos, u64(rtl), u64(stl))
def next(self, index=0): def next(self, index=0):
if self._file is None: if self._file is None:
......
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