bdiff: simple splitlines optimization
authorChristoph Spiel <cspiel@freenet.de>
Thu, 27 Sep 2007 23:58:54 -0500
changeset 5340 5737845fd974
parent 5339 058e93c3d07d
child 5341 458acf92b49e
bdiff: simple splitlines optimization
mercurial/bdiff.c
--- a/mercurial/bdiff.c	Thu Sep 27 23:57:57 2007 -0500
+++ b/mercurial/bdiff.c	Thu Sep 27 23:58:54 2007 -0500
@@ -67,12 +67,13 @@
 {
 	int g, h, i;
 	const char *p, *b = a;
+	const char * const plast = a + len - 1;
 	struct line *l;
 
 	/* count the lines */
 	i = 1; /* extra line for sentinel */
 	for (p = a; p < a + len; p++)
-		if (*p == '\n' || p == a + len - 1)
+		if (*p == '\n' || p == plast)
 			i++;
 
 	*lr = l = (struct line *)malloc(sizeof(struct line) * i);
@@ -92,7 +93,7 @@
 			h ^= g >> 24;
 			h ^= g;
 		}
-		if (*p == '\n' || p == a + len - 1) {
+		if (*p == '\n' || p == plast) {
 			l->len = p - b + 1;
 			l->h = h * l->len;
 			l->l = b;