changeset 38820:44bbc89ec5e0

revlog: remove micro-optimization for looking up only nullid index_find_node() would call nt_find() before initializing the node tree. nt_find() would then return -2 unless the requested revision was the null revision. I can't imagine what scenario that is optimizing for, and doing the initialization earlier makes the code simpler and easier to follow, so that's what this patch does. Differential Revision: https://phab.mercurial-scm.org/D4027
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 08 Jul 2018 23:39:32 -0700
parents 49628742d264
children d814bbd22946
files mercurial/cext/revlog.c
diffstat 1 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/revlog.c	Fri Jul 20 23:57:25 2018 -0700
+++ b/mercurial/cext/revlog.c	Sun Jul 08 23:39:32 2018 -0700
@@ -994,9 +994,6 @@
 	if (nodelen == 20 && node[0] == '\0' && memcmp(node, nullid, 20) == 0)
 		return -1;
 
-	if (self->nt == NULL)
-		return -2;
-
 	if (hex)
 		maxlevel = nodelen > 40 ? 40 : (int)nodelen;
 	else
@@ -1133,14 +1130,14 @@
 {
 	int rev;
 
+	if (nt_init(self) == -1)
+		return -3;
+
 	self->ntlookups++;
 	rev = nt_find(self, node, nodelen, 0);
 	if (rev >= -1)
 		return rev;
 
-	if (nt_init(self) == -1)
-		return -3;
-
 	/*
 	 * For the first handful of lookups, we scan the entire index,
 	 * and cache only the matching nodes. This optimizes for cases