D4166: index: make capacity argument to nt_init be measured in revisions

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sun Aug 12 00:46:20 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG34eb999e29bf: index: make capacity argument to nt_init be measured in revisions (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4166?vs=10092&id=10339

REVISION DETAIL
  https://phab.mercurial-scm.org/D4166

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1065,7 +1065,9 @@
 static int nt_init(nodetree *self, indexObject *index, unsigned capacity)
 {
 	self->index = index;
-	self->capacity = capacity;
+	/* The input capacity is in terms of revisions, while the field is in
+	 * terms of nodetree nodes. */
+	self->capacity = (capacity < 4 ? 4 : capacity / 2);
 	self->depth = 0;
 	self->splits = 0;
 	if ((size_t)self->capacity > INT_MAX / sizeof(nodetreenode)) {
@@ -1141,8 +1143,7 @@
 			PyErr_NoMemory();
 			return -1;
 		}
-		unsigned capacity = (self->raw_length < 4 ? 4 : (int)self->raw_length / 2);
-		if (nt_init(self->nt, self, capacity) == -1) {
+		if (nt_init(self->nt, self, self->raw_length) == -1) {
 			PyMem_Free(self->nt);
 			self->nt = NULL;
 			return -1;



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list