delta-find: clarify some comment and code in is_good_delta_info
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 04 Jan 2024 15:35:57 +0100
changeset 51342 410afe5b13fc
parent 51341 176d530f59af
child 51343 5c0693553cb6
delta-find: clarify some comment and code in is_good_delta_info We move the comment closer to the code it describ and we compute an intermediate value without using the `textlen` variable, as it will stop being defined in a future patch. This will clarify future patches.
mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py	Thu Jan 04 15:35:36 2024 +0100
+++ b/mercurial/revlogutils/deltas.py	Thu Jan 04 15:35:57 2024 +0100
@@ -1066,9 +1066,6 @@
 
         # - 'deltainfo.distance' is the distance from the base revision --
         #   bounding it limits the amount of I/O we need to do.
-        # - 'deltainfo.compresseddeltalen' is the sum of the total size of
-        #   deltas we need to apply -- bounding it limits the amount of CPU
-        #   we consume.
 
         textlen = self.revinfo.textlen
         defaultmax = textlen * 4
@@ -1094,8 +1091,12 @@
 
         # Bad delta from cumulated payload size:
         #
+        # - 'deltainfo.compresseddeltalen' is the sum of the total size of
+        #   deltas we need to apply -- bounding it limits the amount of CPU
+        #   we consume.
+        max_chain_data = self.revinfo.textlen * LIMIT_DELTA2TEXT
         #   If the sum of delta get larger than K * target text length.
-        if textlen * LIMIT_DELTA2TEXT < deltainfo.compresseddeltalen:
+        if max_chain_data < deltainfo.compresseddeltalen:
             return False
 
         # Bad delta from chain length: