revlog: avoid some unnecessary seek/tell syscalls
authorMatt Mackall <mpm@selenic.com>
Mon, 23 Jul 2007 20:44:08 -0500
changeset 4996 a0d37976cd5b
parent 4995 e45fc5d03798
child 4998 81f8ff2a9bf2
revlog: avoid some unnecessary seek/tell syscalls
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Jul 23 20:44:08 2007 -0500
+++ b/mercurial/revlog.py	Mon Jul 23 20:44:08 2007 -0500
@@ -1029,8 +1029,8 @@
             dfh.flush()
             ifh.write(entry)
         else:
-            ifh.seek(0, 2)
-            transaction.add(self.indexfile, ifh.tell(), prev)
+            offset += curr * self._io.size
+            transaction.add(self.indexfile, offset, prev)
             ifh.write(entry)
             ifh.write(data[0])
             ifh.write(data[1])
@@ -1106,11 +1106,12 @@
             end = self.end(t)
 
         ifh = self.opener(self.indexfile, "a+")
-        ifh.seek(0, 2)
-        transaction.add(self.indexfile, ifh.tell(), self.count())
+        isize = r * self._io.size
         if self._inline:
+            transaction.add(self.indexfile, end + isize, r)
             dfh = None
         else:
+            transaction.add(self.indexfile, isize, r)
             transaction.add(self.datafile, end)
             dfh = self.opener(self.datafile, "a")