564 _rbcnames = b'rbc-names' + _rbcversion |
564 _rbcnames = b'rbc-names' + _rbcversion |
565 _rbcrevs = b'rbc-revs' + _rbcversion |
565 _rbcrevs = b'rbc-revs' + _rbcversion |
566 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] |
566 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] |
567 _rbcrecfmt = b'>4sI' |
567 _rbcrecfmt = b'>4sI' |
568 _rbcrecsize = calcsize(_rbcrecfmt) |
568 _rbcrecsize = calcsize(_rbcrecfmt) |
|
569 _rbcmininc = 64 * _rbcrecsize |
569 _rbcnodelen = 4 |
570 _rbcnodelen = 4 |
570 _rbcbranchidxmask = 0x7FFFFFFF |
571 _rbcbranchidxmask = 0x7FFFFFFF |
571 _rbccloseflag = 0x80000000 |
572 _rbccloseflag = 0x80000000 |
572 |
573 |
573 |
574 |
728 def _setcachedata(self, rev, node, branchidx): |
729 def _setcachedata(self, rev, node, branchidx): |
729 """Writes the node's branch data to the in-memory cache data.""" |
730 """Writes the node's branch data to the in-memory cache data.""" |
730 if rev == nullrev: |
731 if rev == nullrev: |
731 return |
732 return |
732 rbcrevidx = rev * _rbcrecsize |
733 rbcrevidx = rev * _rbcrecsize |
733 if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: |
734 requiredsize = rbcrevidx + _rbcrecsize |
734 self._rbcrevs.extend( |
735 rbccur = len(self._rbcrevs) |
735 b'\0' |
736 if rbccur < requiredsize: |
736 * (len(self._repo.changelog) * _rbcrecsize - len(self._rbcrevs)) |
737 # bytearray doesn't allocate extra space at least in Python 3.7. |
737 ) |
738 # When multiple changesets are added in a row, precise resize would |
|
739 # result in quadratic complexity. Overallocate to compensate by |
|
740 # use the classic doubling technique for dynamic arrays instead. |
|
741 # If there was a gap in the map before, less space will be reserved. |
|
742 self._rbcrevs.extend(b'\0' * max(_rbcmininc, requiredsize)) |
738 pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx) |
743 pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx) |
739 self._rbcrevslen = min(self._rbcrevslen, rev) |
744 self._rbcrevslen = min(self._rbcrevslen, rev) |
740 |
745 |
741 tr = self._repo.currenttransaction() |
746 tr = self._repo.currenttransaction() |
742 if tr: |
747 if tr: |