diff options
author | Evan Martin <martine@danga.com> | 2011-09-12 18:44:12 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-09-12 18:46:18 (GMT) |
commit | 3fbb25b2cc66f236a39b728d20e5d44da23612ac (patch) | |
tree | d6eb7c1bc63ef3d4d4d1056750756dc581da5ef0 /src/build_log.cc | |
parent | f1139aff5deddacd899be064fad9ed5a185e7444 (diff) | |
download | Ninja-3fbb25b2cc66f236a39b728d20e5d44da23612ac.zip Ninja-3fbb25b2cc66f236a39b728d20e5d44da23612ac.tar.gz Ninja-3fbb25b2cc66f236a39b728d20e5d44da23612ac.tar.bz2 |
generalize the pattern of hash_map<const char*, ...>, use in BuildLog
Refactor the code in StatCache for use in BuildLog. Now both use
hash tables where the keys are const char*. Removes another 30ms
from Chrome no-op builds.
Diffstat (limited to 'src/build_log.cc')
-rw-r--r-- | src/build_log.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/build_log.cc b/src/build_log.cc index b21a755..79143bf 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -91,15 +91,15 @@ void BuildLog::RecordCommand(Edge* edge, int start_time, int end_time) { for (vector<Node*>::iterator out = edge->outputs_.begin(); out != edge->outputs_.end(); ++out) { const string& path = (*out)->file_->path_; - Log::iterator i = log_.find(path); + Log::iterator i = log_.find(path.c_str()); LogEntry* log_entry; if (i != log_.end()) { log_entry = i->second; } else { log_entry = new LogEntry; - log_.insert(make_pair(path, log_entry)); + log_entry->output = path; + log_.insert(make_pair(log_entry->output.c_str(), log_entry)); } - log_entry->output = path; log_entry->command = command; log_entry->start_time = start_time; log_entry->end_time = end_time; @@ -171,17 +171,17 @@ bool BuildLog::Load(const string& path, string* err) { continue; LogEntry* entry; - Log::iterator i = log_.find(output); + Log::iterator i = log_.find(output.c_str()); if (i != log_.end()) { entry = i->second; } else { entry = new LogEntry; - log_.insert(make_pair(output, entry)); + entry->output = output; + log_.insert(make_pair(entry->output.c_str(), entry)); ++unique_entry_count; } ++total_entry_count; - entry->output = output; entry->start_time = start_time; entry->end_time = end_time; entry->command = string(start, end - start); @@ -205,7 +205,7 @@ bool BuildLog::Load(const string& path, string* err) { } BuildLog::LogEntry* BuildLog::LookupByOutput(const string& path) { - Log::iterator i = log_.find(path); + Log::iterator i = log_.find(path.c_str()); if (i != log_.end()) return i->second; return NULL; |