From 8e20867e1de55489d47ec65552a2f561126c070b Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 6 Jan 2014 16:15:23 -0800 Subject: Make BuildLogUser reference constant. --- src/build_log.cc | 5 +++-- src/build_log.h | 6 +++--- src/build_log_perftest.cc | 2 +- src/build_log_test.cc | 4 ++-- src/build_test.cc | 2 +- src/ninja.cc | 2 +- src/state.cc | 4 ++-- src/state.h | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/build_log.cc b/src/build_log.cc index c041514..3f24c16 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -108,7 +108,7 @@ BuildLog::~BuildLog() { Close(); } -bool BuildLog::OpenForWrite(const string& path, BuildLogUser& user, +bool BuildLog::OpenForWrite(const string& path, const BuildLogUser& user, string* err) { if (needs_recompaction_) { if (!Recompact(path, user, err)) @@ -351,7 +351,8 @@ bool BuildLog::WriteEntry(FILE* f, const LogEntry& entry) { entry.output.c_str(), entry.command_hash) > 0; } -bool BuildLog::Recompact(const string& path, BuildLogUser& user, string* err) { +bool BuildLog::Recompact(const string& path, const BuildLogUser& user, + string* err) { METRIC_RECORD(".ninja_log recompact"); printf("Recompacting log...\n"); diff --git a/src/build_log.h b/src/build_log.h index fc44854..fe81a85 100644 --- a/src/build_log.h +++ b/src/build_log.h @@ -29,7 +29,7 @@ struct Edge; struct BuildLogUser { /// Return if a given output no longer part of the build manifest. /// This is only called during recompaction and doesn't have to be fast. - virtual bool IsPathDead(StringPiece s) = 0; + virtual bool IsPathDead(StringPiece s) const = 0; }; /// Store a log of every command ran for every build. @@ -43,7 +43,7 @@ struct BuildLog { BuildLog(); ~BuildLog(); - bool OpenForWrite(const string& path, BuildLogUser& user, string* err); + bool OpenForWrite(const string& path, const BuildLogUser& user, string* err); bool RecordCommand(Edge* edge, int start_time, int end_time, TimeStamp restat_mtime = 0); void Close(); @@ -79,7 +79,7 @@ struct BuildLog { bool WriteEntry(FILE* f, const LogEntry& entry); /// Rewrite the known log entries, throwing away old data. - bool Recompact(const string& path, BuildLogUser& user, string* err); + bool Recompact(const string& path, const BuildLogUser& user, string* err); typedef ExternalStringHashMap::Type Entries; const Entries& entries() const { return entries_; } diff --git a/src/build_log_perftest.cc b/src/build_log_perftest.cc index 12cae99..810c065 100644 --- a/src/build_log_perftest.cc +++ b/src/build_log_perftest.cc @@ -29,7 +29,7 @@ const char kTestFilename[] = "BuildLogPerfTest-tempfile"; struct NoDeadPaths : public BuildLogUser { - virtual bool IsPathDead(StringPiece) { return false; } + virtual bool IsPathDead(StringPiece) const { return false; } }; bool WriteTestData(string* err) { diff --git a/src/build_log_test.cc b/src/build_log_test.cc index 55f8560..6738c7b 100644 --- a/src/build_log_test.cc +++ b/src/build_log_test.cc @@ -38,7 +38,7 @@ struct BuildLogTest : public StateTestWithBuiltinRules, public BuildLogUser { virtual void TearDown() { unlink(kTestFilename); } - virtual bool IsPathDead(StringPiece s) { return false; } + virtual bool IsPathDead(StringPiece s) const { return false; } }; TEST_F(BuildLogTest, WriteRead) { @@ -263,7 +263,7 @@ TEST_F(BuildLogTest, MultiTargetEdge) { } struct BuildLogRecompactTest : public BuildLogTest { - virtual bool IsPathDead(StringPiece s) { return s == "out2"; } + virtual bool IsPathDead(StringPiece s) const { return s == "out2"; } }; TEST_F(BuildLogRecompactTest, Recompact) { diff --git a/src/build_test.cc b/src/build_test.cc index 8a7fc20..86a911b 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -435,7 +435,7 @@ struct BuildTest : public StateTestWithBuiltinRules, public BuildLogUser { builder_.command_runner_.release(); } - virtual bool IsPathDead(StringPiece s) { return false; } + virtual bool IsPathDead(StringPiece s) const { return false; } /// Rebuild target in the 'working tree' (fs_). /// State of command_runner_ and logs contents (if specified) ARE MODIFIED. diff --git a/src/ninja.cc b/src/ninja.cc index 008c052..03ca83b 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -138,7 +138,7 @@ struct NinjaMain : public BuildLogUser { /// Dump the output requested by '-d stats'. void DumpMetrics(); - virtual bool IsPathDead(StringPiece s) { + virtual bool IsPathDead(StringPiece s) const { Node* n = state_.LookupNode(s); // Just checking n isn't enough: If an old output is both in the build log // and in the deps log, it will have a Node object in state_. (It will also diff --git a/src/state.cc b/src/state.cc index 9b6160b..33f8423 100644 --- a/src/state.cc +++ b/src/state.cc @@ -118,9 +118,9 @@ Node* State::GetNode(StringPiece path) { return node; } -Node* State::LookupNode(StringPiece path) { +Node* State::LookupNode(StringPiece path) const { METRIC_RECORD("lookup node"); - Paths::iterator i = paths_.find(path); + Paths::const_iterator i = paths_.find(path); if (i != paths_.end()) return i->second; return NULL; diff --git a/src/state.h b/src/state.h index bde75ff..bcb0eff 100644 --- a/src/state.h +++ b/src/state.h @@ -95,7 +95,7 @@ struct State { Edge* AddEdge(const Rule* rule); Node* GetNode(StringPiece path); - Node* LookupNode(StringPiece path); + Node* LookupNode(StringPiece path) const; Node* SpellcheckNode(const string& path); void AddIn(Edge* edge, StringPiece path); -- cgit v0.12