summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2012-05-04 21:25:32 (GMT)
committerNico Weber <thakis@chromium.org>2012-05-04 21:25:32 (GMT)
commit0277930c56b46d98426f5df3ae2618b589a79f67 (patch)
treebee9fcb50ea35b90bbc19ac4f4caf797eddb82aa /src
parente405f07e52417b5be95094d0f1f8a23e30ec956f (diff)
downloadNinja-0277930c56b46d98426f5df3ae2618b589a79f67.zip
Ninja-0277930c56b46d98426f5df3ae2618b589a79f67.tar.gz
Ninja-0277930c56b46d98426f5df3ae2618b589a79f67.tar.bz2
First check for string end, then dereference. (5ms more expensive, heh.)
Diffstat (limited to 'src')
-rw-r--r--src/util.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util.cc b/src/util.cc
index 49b079c..d8d7fb3 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -114,11 +114,11 @@ bool CanonicalizePath(char* path, int* len, string* err) {
while (src < end) {
if (*src == '.') {
- if (src[1] == '/' || src + 1 == end) {
+ if (src + 1 == end || src[1] == '/') {
// '.' component; eliminate.
src += 2;
continue;
- } else if (src[1] == '.' && (src[2] == '/' || src + 2 == end)) {
+ } else if (src[1] == '.' && (src + 2 == end || src[2] == '/')) {
// '..' component. Back up if possible.
if (component_count > 0) {
dst = components[component_count - 1];