summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2012-05-04 01:18:03 (GMT)
committerNico Weber <thakis@chromium.org>2012-05-04 01:18:03 (GMT)
commite405f07e52417b5be95094d0f1f8a23e30ec956f (patch)
tree48ddefd463ada2eedd83f61d20d6f54210213a48 /src
parent1dc38391fe5e016fd877126337ca97a971d97e77 (diff)
downloadNinja-e405f07e52417b5be95094d0f1f8a23e30ec956f.zip
Ninja-e405f07e52417b5be95094d0f1f8a23e30ec956f.tar.gz
Ninja-e405f07e52417b5be95094d0f1f8a23e30ec956f.tar.bz2
Don't walk path components twice. Speeds up CanonicalizePath() 115ms (285ms -> 170ms).
Diffstat (limited to 'src')
-rw-r--r--src/util.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/util.cc b/src/util.cc
index de535b3..49b079c 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -143,13 +143,9 @@ bool CanonicalizePath(char* path, int* len, string* err) {
components[component_count] = dst;
++component_count;
- const char* sep = (const char*)memchr(src, '/', end - src);
- if (sep == NULL)
- sep = end;
- while (src <= sep) {
+ while (*src != '/' && src != end)
*dst++ = *src++;
- }
- src = sep + 1;
+ *dst++ = *src++; // Copy '/' or final \0 character as well.
}
if (dst == start) {