diff options
author | Pietro Cerutti <gahr@gahr.ch> | 2017-04-11 10:53:40 (GMT) |
---|---|---|
committer | Pietro Cerutti <gahr@gahr.ch> | 2017-04-11 10:53:40 (GMT) |
commit | 87efe5f206fe138a1e88238153212c5cbac401cd (patch) | |
tree | 91b28cf8666165674f4a1b4762d7c878b3075e31 /src/disk_interface.cc | |
parent | 0b0374e831d9c050c6c9eb2ef48b73bc62a0f084 (diff) | |
download | Ninja-87efe5f206fe138a1e88238153212c5cbac401cd.zip Ninja-87efe5f206fe138a1e88238153212c5cbac401cd.tar.gz Ninja-87efe5f206fe138a1e88238153212c5cbac401cd.tar.bz2 |
DirName's separators and their length are known at compile time
Diffstat (limited to 'src/disk_interface.cc')
-rw-r--r-- | src/disk_interface.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc index 1b4135f..40796ed 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -34,14 +34,15 @@ namespace { string DirName(const string& path) { #ifdef _WIN32 - const char kPathSeparators[] = "\\/"; + static const char kPathSeparators[] = "\\/"; #else - const char kPathSeparators[] = "/"; + static const char kPathSeparators[] = "/"; #endif + static const char* const kEnd = kPathSeparators + sizeof(kPathSeparators) - 1; + string::size_type slash_pos = path.find_last_of(kPathSeparators); if (slash_pos == string::npos) return string(); // Nothing to do. - const char* const kEnd = kPathSeparators + strlen(kPathSeparators); while (slash_pos > 0 && std::find(kPathSeparators, kEnd, path[slash_pos - 1]) != kEnd) --slash_pos; |