Mercurial > hg
changeset 42487:5ceb91136ebe
copies: avoid unnecessary copying of copy dict
When storing copy information in the changesets, this patch speeds up
hg debugpathcopies FENNEC_58_0_2_BUILD1 FIREFOX_59_0b8_BUILD2
from 11s to 5.9s. That command takes 6.2s when storing copy
information in filelogs.
Differential Revision: https://phab.mercurial-scm.org/D6421
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 18 Apr 2019 21:21:44 -0700 |
parents | 35d674a3d5db |
children | c0b51449bf6b |
files | mercurial/copies.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/copies.py Thu Apr 18 21:22:14 2019 -0700 +++ b/mercurial/copies.py Thu Apr 18 21:21:44 2019 -0700 @@ -297,7 +297,7 @@ if r == b.rev(): _filter(a, b, copies) return copies - for c in children[r]: + for i, c in enumerate(children[r]): childctx = repo[c] if r == childctx.p1().rev(): parent = 1 @@ -309,7 +309,13 @@ if not match.always(): childcopies = {dst: src for dst, src in childcopies.items() if match(dst)} - childcopies = _chain(copies, childcopies) + # Copy the dict only if later iterations will also need it + if i != len(children[r]) - 1: + copies = copies.copy() + if childcopies: + childcopies = _chain(copies, childcopies) + else: + childcopies = copies for f in childctx.filesremoved(): if f in childcopies: del childcopies[f]