diff options
author | Evan Martin <martine@danga.com> | 2012-01-09 21:35:16 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-01-09 21:35:16 (GMT) |
commit | 5aa69297e47109bd5d2cc8db6907af56ff100d6d (patch) | |
tree | dece8061a67308ea9da132dfe4f48a48335fa7dd /src | |
parent | a844fba695d4a62d4ae5bf98c6df3b0677df18b2 (diff) | |
download | Ninja-5aa69297e47109bd5d2cc8db6907af56ff100d6d.zip Ninja-5aa69297e47109bd5d2cc8db6907af56ff100d6d.tar.gz Ninja-5aa69297e47109bd5d2cc8db6907af56ff100d6d.tar.bz2 |
more stringpiece
Diffstat (limited to 'src')
-rw-r--r-- | src/hash_map.h | 2 | ||||
-rw-r--r-- | src/state.cc | 13 | ||||
-rw-r--r-- | src/state.h | 6 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/hash_map.h b/src/hash_map.h index 7cbd052..3ad4d73 100644 --- a/src/hash_map.h +++ b/src/hash_map.h @@ -19,7 +19,7 @@ static const unsigned int kSeed = 0xDECAFBAD; // MurmurHash2, by Austin Appleby -static +static inline unsigned int MurmurHash2(const void* key, int len, unsigned int seed) { const unsigned int m = 0x5bd1e995; const int r = 24; diff --git a/src/state.cc b/src/state.cc index 7e3aae8..9f38fe9 100644 --- a/src/state.cc +++ b/src/state.cc @@ -19,6 +19,7 @@ #include "edit_distance.h" #include "graph.h" +#include "metrics.h" #include "util.h" const Rule State::kPhonyRule("phony"); @@ -57,6 +58,7 @@ Node* State::GetNode(StringPiece path) { } Node* State::LookupNode(StringPiece path) { + METRIC_RECORD("lookup node"); Paths::iterator i = paths_.find(path); if (i != paths_.end()) return i->second; @@ -80,26 +82,27 @@ Node* State::SpellcheckNode(const string& path) { return result; } -void State::AddIn(Edge* edge, const string& path) { +void State::AddIn(Edge* edge, StringPiece path) { Node* node = GetNode(path); edge->inputs_.push_back(node); node->AddOutEdge(edge); } -void State::AddOut(Edge* edge, const string& path) { +void State::AddOut(Edge* edge, StringPiece path) { Node* node = GetNode(path); edge->outputs_.push_back(node); if (node->in_edge()) { Warning("multiple rules generate %s. " - "build will not be correct; continuing anyway", path.c_str()); + "build will not be correct; continuing anyway", + path.AsString().c_str()); } node->set_in_edge(edge); } -bool State::AddDefault(const string& path, string* err) { +bool State::AddDefault(StringPiece path, string* err) { Node* node = LookupNode(path); if (!node) { - *err = "unknown target '" + path + "'"; + *err = "unknown target '" + path.AsString() + "'"; return false; } defaults_.push_back(node); diff --git a/src/state.h b/src/state.h index 72ced9f..845c947 100644 --- a/src/state.h +++ b/src/state.h @@ -44,9 +44,9 @@ struct State { Node* LookupNode(StringPiece path); Node* SpellcheckNode(const string& path); - void AddIn(Edge* edge, const string& path); - void AddOut(Edge* edge, const string& path); - bool AddDefault(const string& path, string* error); + void AddIn(Edge* edge, StringPiece path); + void AddOut(Edge* edge, StringPiece path); + bool AddDefault(StringPiece path, string* error); /// Reset state. Keeps all nodes and edges, but restores them to the /// state where we haven't yet examined the disk for dirty state. |