##// END OF EJS Templates
dirstate: isolate node len dependency for the pure version...
Joerg Sonnenberger -
r45778:4f0e03d9 default
parent child Browse files
Show More
@@ -1425,6 +1425,7 b' class dirstatemap(object):'
1425 1425 self._opener = opener
1426 1426 self._root = root
1427 1427 self._filename = b'dirstate'
1428 self._nodelen = 20
1428 1429
1429 1430 self._parents = None
1430 1431 self._dirtyparents = False
@@ -1609,7 +1610,7 b' class dirstatemap(object):'
1609 1610 if not self._parents:
1610 1611 try:
1611 1612 fp = self._opendirstatefile()
1612 st = fp.read(40)
1613 st = fp.read(2 * self._nodelen)
1613 1614 fp.close()
1614 1615 except IOError as err:
1615 1616 if err.errno != errno.ENOENT:
@@ -1618,8 +1619,11 b' class dirstatemap(object):'
1618 1619 st = b''
1619 1620
1620 1621 l = len(st)
1621 if l == 40:
1622 self._parents = (st[:20], st[20:40])
1622 if l == self._nodelen * 2:
1623 self._parents = (
1624 st[: self._nodelen],
1625 st[self._nodelen : 2 * self._nodelen],
1626 )
1623 1627 elif l == 0:
1624 1628 self._parents = (nullid, nullid)
1625 1629 else:
@@ -1655,15 +1659,17 b' class dirstatemap(object):'
1655 1659 if util.safehasattr(parsers, b'dict_new_presized'):
1656 1660 # Make an estimate of the number of files in the dirstate based on
1657 1661 # its size. From a linear regression on a set of real-world repos,
1658 # all over 10,000 files, the size of a dirstate entry is 85
1659 # bytes. The cost of resizing is significantly higher than the cost
1662 # all over 10,000 files, the size of a dirstate entry is 2 nodes
1663 # plus 45 bytes. The cost of resizing is significantly higher than the cost
1660 1664 # of filling in a larger presized dict, so subtract 20% from the
1661 1665 # size.
1662 1666 #
1663 1667 # This heuristic is imperfect in many ways, so in a future dirstate
1664 1668 # format update it makes sense to just record the number of entries
1665 1669 # on write.
1666 self._map = parsers.dict_new_presized(len(st) // 71)
1670 self._map = parsers.dict_new_presized(
1671 len(st) // ((2 * self._nodelen + 45) * 4 // 5)
1672 )
1667 1673
1668 1674 # Python's garbage collector triggers a GC each time a certain number
1669 1675 # of container objects (the number being defined by
@@ -1829,7 +1835,7 b' if rustmod is not None:'
1829 1835 if not self._parents:
1830 1836 try:
1831 1837 fp = self._opendirstatefile()
1832 st = fp.read(40)
1838 st = fp.read(2 * self._nodelen)
1833 1839 fp.close()
1834 1840 except IOError as err:
1835 1841 if err.errno != errno.ENOENT:
General Comments 0
You need to be logged in to leave comments. Login now