diff options
author | tikuta <tikuta@google.com> | 2017-04-12 05:40:40 (GMT) |
---|---|---|
committer | Takuto Ikuta <tikuta@chromium.org> | 2017-05-08 09:34:36 (GMT) |
commit | 3b320023276f98b978054c14c65d3888b989ff4a (patch) | |
tree | 7454ece5d1d4c8be8b1d2217072707d06792aec4 /src/clparser.cc | |
parent | 08a3220bc2fe12e7f05967b317d221e0bc620be9 (diff) | |
download | Ninja-3b320023276f98b978054c14c65d3888b989ff4a.zip Ninja-3b320023276f98b978054c14c65d3888b989ff4a.tar.gz Ninja-3b320023276f98b978054c14c65d3888b989ff4a.tar.bz2 |
Make clparser faster
This patch improves perfromance of clparser.
* Reduce the number of calling GetFullPathName.
* Use StringPiece for Split and Join.
* Add EqualsCaseInsensitive for StringPiece not to generate new string
instance.
* Add some utility member in StringPiece class.
Diffstat (limited to 'src/clparser.cc')
-rw-r--r-- | src/clparser.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/clparser.cc b/src/clparser.cc index c17150b..c993e36 100644 --- a/src/clparser.cc +++ b/src/clparser.cc @@ -18,8 +18,11 @@ #include <assert.h> #include <string.h> +#include "metrics.h" + #ifdef _WIN32 #include "includes_normalize.h" +#include "string_piece.h" #else #include "util.h" #endif @@ -72,9 +75,15 @@ bool CLParser::FilterInputFilename(string line) { // static bool CLParser::Parse(const string& output, const string& deps_prefix, string* filtered_output, string* err) { + METRIC_RECORD("CLParser::Parse"); + // Loop over all lines in the output to process them. assert(&output != filtered_output); size_t start = 0; +#ifdef _WIN32 + IncludesNormalize normalizer("."); +#endif + while (start < output.size()) { size_t end = output.find_first_of("\r\n", start); if (end == string::npos) @@ -85,7 +94,7 @@ bool CLParser::Parse(const string& output, const string& deps_prefix, if (!include.empty()) { string normalized; #ifdef _WIN32 - if (!IncludesNormalize::Normalize(include, NULL, &normalized, err)) + if (!normalizer.Normalize(include, &normalized, err)) return false; #else // TODO: should this make the path relative to cwd? |