diff options
author | Nico Weber <thakis@chromium.org> | 2012-05-04 01:14:34 (GMT) |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2012-05-04 01:14:34 (GMT) |
commit | fa34c6da1ff24493f6c28a8a708540268b63d013 (patch) | |
tree | 8cd3f00c12a109e742b762440aff962acf782d07 | |
parent | 8be4ffbaac5e88bf4da8e537ffdbecccbb916170 (diff) | |
download | Ninja-fa34c6da1ff24493f6c28a8a708540268b63d013.zip Ninja-fa34c6da1ff24493f6c28a8a708540268b63d013.tar.gz Ninja-fa34c6da1ff24493f6c28a8a708540268b63d013.tar.bz2 |
Skip single '/' characters earlier in the loop. 300ms -> 285ms.
-rw-r--r-- | src/util.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/util.cc b/src/util.cc index 6bafc91..dfae8d6 100644 --- a/src/util.cc +++ b/src/util.cc @@ -133,18 +133,21 @@ bool CanonicalizePath(char* path, int* len, string* err) { } } + if (*src == '/') { + src++; + continue; + } + const char* sep = (const char*)memchr(src, '/', end - src); if (sep == NULL) sep = end; - if (sep > src) { - if (component_count == kMaxPathComponents) - Fatal("path has too many components"); - components[component_count] = dst; - ++component_count; - while (src <= sep) { - *dst++ = *src++; - } + if (component_count == kMaxPathComponents) + Fatal("path has too many components"); + components[component_count] = dst; + ++component_count; + while (src <= sep) { + *dst++ = *src++; } src = sep + 1; |