projects
/
platform
/
upstream
/
ninja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1dc3839
)
Don't walk path components twice. Speeds up CanonicalizePath() 115ms (285ms -> 170ms).
author
Nico Weber
<thakis@chromium.org>
Fri, 4 May 2012 01:18:03 +0000
(18:18 -0700)
committer
Nico Weber
<thakis@chromium.org>
Fri, 4 May 2012 01:18:03 +0000
(18:18 -0700)
src/util.cc
patch
|
blob
|
history
diff --git
a/src/util.cc
b/src/util.cc
index de535b3d8ebd61bfcc96e33c8c59172fdea02767..49b079cb60c52a6fdd2481b9936401663c94b500 100644
(file)
--- 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) {