From 5aa69297e47109bd5d2cc8db6907af56ff100d6d Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Mon, 9 Jan 2012 13:35:16 -0800 Subject: more stringpiece --- src/hash_map.h | 2 +- src/state.cc | 13 ++++++++----- 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. -- cgit v0.12