# HG changeset patch # User Siddharth Agarwal # Date 1405213143 25200 # Node ID e6754f5e4cf79245ca16303e639491a04e3d0430 # Parent 090dcaaf3fffa126b161c7525354efbf240043e7 context: generate filtered manifest efficiently for exact matchers When the matcher is exact, there's no reason to iterate over the entire manifest. It's much more efficient to iterate over the list of files instead. For a repository with approximately 300,000 files, this speeds up hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds to 10.5 seconds. diff -r 090dcaaf3fff -r e6754f5e4cf7 mercurial/context.py --- a/mercurial/context.py Sat Jul 12 17:57:25 2014 -0700 +++ b/mercurial/context.py Sat Jul 12 17:59:03 2014 -0700 @@ -71,9 +71,13 @@ object oriented way for other contexts to customize the manifest generation. """ + if match.always(): + return self.manifest().copy() + + if match.matchfn == match.exact: + return self.manifest().intersectfiles(match.files()) + mf = self.manifest().copy() - if match.always(): - return mf for fn in mf.keys(): if not match(fn): del mf[fn]