Mercurial > hg
changeset 6144:08e0825b8106
revlog.revision: avoid opening the datafile without need.
If there's no inline data, revlog.revision opens the data file every
time it's called. This is useful if we're going to call chunk many
times, but, if we're going to call it only once, it's better to let
chunk open the file - if we're lucky, all the data we're going to need
is already cached and we won't need to even look at the file.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 19 Feb 2008 19:20:10 -0300 |
parents | 5b159ebb19cf |
children | 154f8be6272b |
files | mercurial/revlog.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Tue Feb 19 10:53:40 2008 -0800 +++ b/mercurial/revlog.py Tue Feb 19 19:20:10 2008 -0300 @@ -933,19 +933,19 @@ raise RevlogError(_('incompatible revision flag %x') % (self.index[rev][0] & 0xFFFF)) - if self._inline: - # we probably have the whole chunk cached - df = None - else: - df = self.opener(self.datafile) + df = None # do we have useful data cached? if self._cache and self._cache[1] >= base and self._cache[1] < rev: base = self._cache[1] text = str(self._cache[2]) self._loadindex(base, rev + 1) + if not self._inline and rev > base + 1: + df = self.opener(self.datafile) else: self._loadindex(base, rev + 1) + if not self._inline and rev > base: + df = self.opener(self.datafile) text = self.chunk(base, df=df) bins = [self.chunk(r, df) for r in xrange(base + 1, rev + 1)]