Mercurial > hg
changeset 6972:63d1d3e489f8
performance: normalize self._root, avoid calling os.path.join() in dirstate
In dirstate, self._join() might get called a lot. Instead of calling it
we create self._rootdir and we then only need to append the filename.
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Tue, 02 Sep 2008 15:12:50 +0200 |
parents | b3bc518a73c3 |
children | 8c136043867b |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Tue Sep 02 15:08:26 2008 +0200 +++ b/mercurial/dirstate.py Tue Sep 02 15:12:50 2008 +0200 @@ -28,6 +28,7 @@ def __init__(self, opener, ui, root): self._opener = opener self._root = root + self._rootdir = os.path.join(root, '') self._dirty = False self._dirtypl = False self._ui = ui @@ -99,13 +100,14 @@ raise AttributeError, name def _join(self, f): - return os.path.join(self._root, f) + # much faster than os.path.join() + return self._rootdir + f def flagfunc(self, fallback): if self._checklink: if self._checkexec: def f(x): - p = os.path.join(self._root, x) + p = self._join(x) if os.path.islink(p): return 'l' if util.is_exec(p): @@ -113,7 +115,7 @@ return '' return f def f(x): - if os.path.islink(os.path.join(self._root, x)): + if os.path.islink(self._join(x)): return 'l' if 'x' in fallback(x): return 'x' @@ -123,7 +125,7 @@ def f(x): if 'l' in fallback(x): return 'l' - if util.is_exec(os.path.join(self._root, x)): + if util.is_exec(self._join(x)): return 'x' return '' return f