summaryrefslogtreecommitdiffstats
path: root/src/util.cc
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2012-05-04 01:14:34 (GMT)
committerNico Weber <thakis@chromium.org>2012-05-04 01:14:34 (GMT)
commitfa34c6da1ff24493f6c28a8a708540268b63d013 (patch)
tree8cd3f00c12a109e742b762440aff962acf782d07 /src/util.cc
parent8be4ffbaac5e88bf4da8e537ffdbecccbb916170 (diff)
downloadNinja-fa34c6da1ff24493f6c28a8a708540268b63d013.zip
Ninja-fa34c6da1ff24493f6c28a8a708540268b63d013.tar.gz
Ninja-fa34c6da1ff24493f6c28a8a708540268b63d013.tar.bz2
Skip single '/' characters earlier in the loop. 300ms -> 285ms.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc19
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;