# HG changeset patch # User Christoph Spiel # Date 1190955534 18000 # Node ID 5737845fd97460b68b45a6ec398bca303ad5b986 # Parent 058e93c3d07d07bf9665bf1d3f8439516c0cb314 bdiff: simple splitlines optimization diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -67,12 +67,13 @@ int splitlines(const char *a, int len, s { 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 @@ int splitlines(const char *a, int len, s 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;