Skip to content

Commit 7c1291e

Browse files
committed
[fdiff.thirdparty.fdifflib] refactor line number tests for autojunk heuristic
moved into the autojunk block so that execution only occurs if it is required
1 parent 0d4fa81 commit 7c1291e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/fdiff/thirdparty/fdifflib.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,18 +352,17 @@ def __chain_b(self):
352352
self.bpopular = popular = set()
353353
n = len(b)
354354

355-
# Define the number of identical lines that must be included
356-
# in order to consider the string "popular" for the autojunk
357-
# strategy. Edited from upstream Python difflib to decrease
358-
# the number of lines as file sizes become larger
359-
if n >= 20000:
360-
ntest = n // 10000 + 1
361-
elif n >= 2000:
362-
ntest = n // 1000 + 1
363-
elif n >= 200:
364-
ntest = n // 100 + 1
365-
366355
if self.autojunk and n >= 200:
356+
# Define the number of identical lines that must be included
357+
# in order to consider the string "popular" for the autojunk
358+
# strategy. Edited from upstream Python difflib to decrease
359+
# the number of lines as file sizes become larger
360+
if n >= 20000:
361+
ntest = n // 10000 + 1
362+
elif n >= 2000:
363+
ntest = n // 1000 + 1
364+
else:
365+
ntest = n // 100 + 1
367366
for elt, idxs in b2j.items():
368367
if len(idxs) > ntest:
369368
popular.add(elt)

0 commit comments

Comments
 (0)