comparison mercurial/revlog.py @ 51894:384016e91947

revlog: simplify rawtext return value We're always returning a tuple even though only the raw text is being used, and we're rebuilding another tuple again higher. As a bonus, this will remove one tuple creation and deletion per `raw_text` call, hence fewer gc calls, etc.
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 19 Jun 2024 17:19:20 +0200
parents eb9dea148233
children b04011ca6eff
comparison
equal deleted inserted replaced
51893:eb9dea148233 51894:384016e91947
1020 return [x[1] for x in chunks] 1020 return [x[1] for x in chunks]
1021 1021
1022 def raw_text(self, node, rev): 1022 def raw_text(self, node, rev):
1023 """return the possibly unvalidated rawtext for a revision 1023 """return the possibly unvalidated rawtext for a revision
1024 1024
1025 returns (rev, rawtext, validated) 1025 returns rawtext
1026 """ 1026 """
1027 1027
1028 # revision in the cache (could be useful to apply delta) 1028 # revision in the cache (could be useful to apply delta)
1029 cachedrev = None 1029 cachedrev = None
1030 # An intermediate text to apply deltas to 1030 # An intermediate text to apply deltas to
1061 basetext = bytes(bins[0]) 1061 basetext = bytes(bins[0])
1062 bins = bins[1:] 1062 bins = bins[1:]
1063 1063
1064 rawtext = mdiff.patches(basetext, bins) 1064 rawtext = mdiff.patches(basetext, bins)
1065 del basetext # let us have a chance to free memory early 1065 del basetext # let us have a chance to free memory early
1066 return (rev, rawtext, False) 1066 return rawtext
1067 1067
1068 def sidedata(self, rev, sidedata_end): 1068 def sidedata(self, rev, sidedata_end):
1069 """Return the sidedata for a given revision number.""" 1069 """Return the sidedata for a given revision number."""
1070 index_entry = self.index[rev] 1070 index_entry = self.index[rev]
1071 sidedata_offset = index_entry[8] 1071 sidedata_offset = index_entry[8]
2759 return (rev, self._inner._revisioncache[2], True) 2759 return (rev, self._inner._revisioncache[2], True)
2760 2760
2761 if rev is None: 2761 if rev is None:
2762 rev = self.rev(node) 2762 rev = self.rev(node)
2763 2763
2764 return self._inner.raw_text(node, rev) 2764 text = self._inner.raw_text(node, rev)
2765 return (rev, text, False)
2765 2766
2766 def _revisiondata(self, nodeorrev, raw=False): 2767 def _revisiondata(self, nodeorrev, raw=False):
2767 # deal with <nodeorrev> argument type 2768 # deal with <nodeorrev> argument type
2768 if isinstance(nodeorrev, int): 2769 if isinstance(nodeorrev, int):
2769 rev = nodeorrev 2770 rev = nodeorrev