# HG changeset patch # User Bryan O'Sullivan # Date 2013-04-03 18:35:27 # Node ID e8b4b139a5451bfc72b24a82f37e19a198f167ee # Parent cafa447a7d3b494d334776de28e02606f297bdbf dirstate: only call lstat once per flags invocation This makes a big difference to performance in some cases. hg --time locate 'set:symlink()' mozilla-central (70,000 files): before: 2.92 sec after: 2.47 another repo (170,000 files): before: 7.87 sec after: 6.86 diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -154,11 +154,14 @@ class dirstate(object): def flagfunc(self, buildfallback): if self._checklink and self._checkexec: def f(x): - p = self._join(x) - if os.path.islink(p): - return 'l' - if util.isexec(p): - return 'x' + try: + st = os.lstat(self._join(x)) + if util.statislink(st): + return 'l' + if util.statisexec(st): + return 'x' + except OSError: + pass return '' return f