Mercurial > hg-stable
changeset 5340:5737845fd974
bdiff: simple splitlines optimization
author | Christoph Spiel <cspiel@freenet.de> |
---|---|
date | Thu, 27 Sep 2007 23:58:54 -0500 |
parents | 058e93c3d07d |
children | 458acf92b49e |
files | mercurial/bdiff.c |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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;