changeset 26043:f2f0a3ab6e41

reachableroots: rename "seen" array to "revstates" for future extension It will be an array of bit flags, SEEN | ROOT | REACHABLE.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 14 Aug 2015 15:23:42 +0900
parents 2a3010ba6f52
children b3ad349d0e50
files mercurial/parsers.c
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/parsers.c	Sat Aug 15 18:29:58 2015 +0900
+++ b/mercurial/parsers.c	Fri Aug 14 15:23:42 2015 +0900
@@ -1130,10 +1130,10 @@
 
 	/* Internal data structure:
 	 * tovisit: array of length len+1 (all revs + nullrev), filled upto lentovisit
-	 * seen: array of length len+1 (all revs + nullrev) 0: not seen, 1 seen*/
+	 * revstates: array of length len+1 (all revs + nullrev) 0: not seen, 1 seen*/
 	int *tovisit = NULL;
 	long lentovisit = 0;
-	char *seen = NULL;
+	char *revstates = NULL;
 
 	/* Get arguments */
 	if (!PyArg_ParseTuple(args, "lO!O!O!", &minroot, &PyList_Type, &heads,
@@ -1157,8 +1157,8 @@
 		goto bail;
 	}
 
-	seen = (char *)calloc(len+1, 1);
-	if (seen == NULL) {
+	revstates = (char *)calloc(len + 1, 1);
+	if (revstates == NULL) {
 		PyErr_NoMemory();
 		goto bail;
 	}
@@ -1173,9 +1173,9 @@
 			PyErr_SetString(PyExc_IndexError, "head out of range");
 			goto bail;
 		}
-		if (seen[revnum+1] == 0) {
+		if (revstates[revnum+1] == 0) {
 			tovisit[lentovisit++] = revnum;
-			seen[revnum+1]=1;
+			revstates[revnum+1]=1;
 		}
 	}
 
@@ -1203,10 +1203,10 @@
 		if (r < 0)
 			goto bail;
 		for (i = 0; i < 2; i++) {
-			if (seen[parents[i] + 1] == 0
+			if (revstates[parents[i] + 1] == 0
 			    && parents[i] >= minroot) {
 				tovisit[lentovisit++] = parents[i];
-				seen[parents[i] + 1] = 1;
+				revstates[parents[i] + 1] = 1;
 			}
 		}
 	}
@@ -1218,7 +1218,7 @@
 		if (minidx < 0)
 			minidx = 0;
 		for (i = minidx; i < len; i++) {
-			if (seen[i + 1] != 1)
+			if (revstates[i + 1] != 1)
 				continue;
 			r = index_get_parents(self, i, parents, (int)len - 1);
 			/* Corrupted index file, error is set from
@@ -1241,12 +1241,12 @@
 		}
 	}
 
-	free(seen);
+	free(revstates);
 	free(tovisit);
 	return reachable;
 bail:
 	Py_XDECREF(reachable);
-	free(seen);
+	free(revstates);
 	free(tovisit);
 	return NULL;
 }