summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakuto Ikuta <tikuta@chromium.org>2017-05-09 15:33:59 +0900
committerTakuto Ikuta <tikuta@google.com>2017-05-09 15:52:33 +0900
commitf0bb90e4bc49167fac5213269a34f628c349e50c (patch)
tree0c398e386cf3cc6d78e410976935bc5480051de3
parent75b338506197921f14e3ce0eb9a04d2787ae1750 (diff)
downloadninja-f0bb90e4bc49167fac5213269a34f628c349e50c.tar.gz
Reduce GetFullPathName calls
-rw-r--r--src/includes_normalize-win32.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/includes_normalize-win32.cc b/src/includes_normalize-win32.cc
index c72783f..459329b 100644
--- a/src/includes_normalize-win32.cc
+++ b/src/includes_normalize-win32.cc
@@ -72,6 +72,7 @@ bool SameDrive(StringPiece a, StringPiece b) {
// Check path |s| is FullPath style returned by GetFullPathName.
// This ignores difference of path separator.
+// This is used not to call very slow GetFullPathName API.
bool IsFullPathName(StringPiece s) {
if (s.size() < 3 ||
!islatinalpha(s[0]) ||
@@ -164,11 +165,12 @@ bool IncludesNormalize::Normalize(const string& input,
if (!CanonicalizePath(copy, &len, &slash_bits, err))
return false;
StringPiece partially_fixed(copy, len);
+ string abs_input = AbsPath(partially_fixed);
- if (!SameDrive(partially_fixed, relative_to_)) {
+ if (!SameDrive(abs_input, relative_to_)) {
*result = partially_fixed.AsString();
return true;
}
- *result = Relativize(partially_fixed, split_relative_to_);
+ *result = Relativize(abs_input, split_relative_to_);
return true;
}