jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340631?usp=email )

Change subject: Reuse context limits when calculating diff ranges
......................................................................

Reuse context limits when calculating diff ranges

Calculate the preceding and following context limits once each, then
reuse them for both versions of the text. Avoid duplicate min() calls
while preserving the resulting ranges.

Change-Id: I14d02ff58581058a0065a1c5ddfbd2da35a66f6b
---
M pywikibot/diff.py
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Mahveotm: Looks good to me, approved




diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index 3e157c4..f7a0bd2 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -368,10 +368,10 @@
         """Dynamically determine context range for a super hunk."""
         a0, a1 = super_hunk.a_rng
         b0, b1 = super_hunk.b_rng
-        return ((a0 - min(super_hunk.pre_context, self.context),
-                 a1 + min(super_hunk.post_context, self.context)),
-                (b0 - min(super_hunk.pre_context, self.context),
-                 b1 + min(super_hunk.post_context, self.context)))
+        pre_context = min(super_hunk.pre_context, self.context)
+        post_context = min(super_hunk.post_context, self.context)
+        return ((a0 - pre_context, a1 + post_context),
+                (b0 - pre_context, b1 + post_context))

     def _generate_diff(self, hunks: _SuperHunk) -> str:
         """Generate a diff text for the given hunks."""

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340631?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I14d02ff58581058a0065a1c5ddfbd2da35a66f6b
Gerrit-Change-Number: 1340631
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Mahveotm <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to