Skip to content

Commit f2dccbc

Browse files
committed
filter-repo: avoid repeatedly translating the same string with --analyze
Translating "Processed %d blob sizes" or "Processed %d commits" hundreds of thousands or millions of times is a waste and turns out to be pretty expensive. Translate it once, cache the string, and then re-use it. Note that a similar issue was noted in commit 3999349 (filter-repo: fix perf regression; avoid excessive translation, 2019-05-21), but I did not think to check --analyze mode for similar issues back then. Fix it now. Signed-off-by: Elijah Newren <[email protected]>
1 parent 9d3d995 commit f2dccbc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git-filter-repo

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@ class GitUtils(object):
15361536
def get_blob_sizes(quiet = False):
15371537
blob_size_progress = ProgressWriter()
15381538
num_blobs = 0
1539+
processed_blobs_msg = _("Processed %d blob sizes")
15391540

15401541
# Get sizes of blobs by sha1
15411542
cmd = '--batch-check=%(objectname) %(objecttype) ' + \
@@ -1553,7 +1554,7 @@ class GitUtils(object):
15531554
packed_size[sha] = objdisksize
15541555
num_blobs += 1
15551556
if not quiet:
1556-
blob_size_progress.show(_("Processed %d blob sizes") % num_blobs)
1557+
blob_size_progress.show(processed_blobs_msg % num_blobs)
15571558
cf.wait()
15581559
if not quiet:
15591560
blob_size_progress.finish()
@@ -2278,6 +2279,7 @@ class RepoAnalyze(object):
22782279
'num_commits': 0}
22792280

22802281
# Setup the rev-list/diff-tree process
2282+
processed_commits_msg = _("Processed %d commits")
22812283
commit_parse_progress = ProgressWriter()
22822284
num_commits = 0
22832285
cmd = ('git rev-list --topo-order --reverse {}'.format(' '.join(args.refs)) +
@@ -2329,7 +2331,7 @@ class RepoAnalyze(object):
23292331
RepoAnalyze.analyze_commit(stats, graph, commit, parents, date,
23302332
file_changes)
23312333
num_commits += 1
2332-
commit_parse_progress.show(_("Processed %d commits") % num_commits)
2334+
commit_parse_progress.show(processed_commits_msg % num_commits)
23332335

23342336
# Show the final commits processed message and record the number of commits
23352337
commit_parse_progress.finish()

0 commit comments

Comments
 (0)