changeset 4996:a0d37976cd5b

revlog: avoid some unnecessary seek/tell syscalls
author Matt Mackall <mpm@selenic.com>
date Mon, 23 Jul 2007 20:44:08 -0500
parents e45fc5d03798
children 81f8ff2a9bf2
files mercurial/revlog.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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")