diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-01-04 05:12:31 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-01-04 05:12:31 (GMT) |
commit | c8b5ad32899503a1f992f7db75fd2c56e8d49238 (patch) | |
tree | 5cc32b2d2074116850860fb1021bb05dc75e2e31 /src/deps_log.cc | |
parent | 637b4572ba9c98b812858a37521af1d442b3ccc4 (diff) | |
download | Ninja-c8b5ad32899503a1f992f7db75fd2c56e8d49238.zip Ninja-c8b5ad32899503a1f992f7db75fd2c56e8d49238.tar.gz Ninja-c8b5ad32899503a1f992f7db75fd2c56e8d49238.tar.bz2 |
Move duplicated code into a helper function.
Diffstat (limited to 'src/deps_log.cc')
-rw-r--r-- | src/deps_log.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/deps_log.cc b/src/deps_log.cc index 157b65c..61df387 100644 --- a/src/deps_log.cc +++ b/src/deps_log.cc @@ -325,18 +325,8 @@ bool DepsLog::Recompact(const string& path, string* err) { Deps* deps = deps_[old_id]; if (!deps) continue; // If nodes_[old_id] is a leaf, it has no deps. - Node* n = nodes_[old_id]; - Edge* e = n->in_edge(); - // FIXME: move this condition to a helper: (also used in src/ninja.cc) - if (!e || e->GetBinding("deps").empty()) { - // Skip entries that don't have in-edges or whose edges don't have a - // "deps" attribute. They were in the deps log from previous builds, but - // the the files they were for were removed from the build and their deps - // entries are no longer needed. - // (Without the check for "deps", a chain of two or more nodes that each - // had deps wouldn't be collected in a single recompaction.) + if (!IsDepsEntryLiveFor(nodes_[old_id])) continue; - } if (!new_log.RecordDeps(nodes_[old_id], deps->mtime, deps->node_count, deps->nodes)) { @@ -364,6 +354,16 @@ bool DepsLog::Recompact(const string& path, string* err) { return true; } +bool DepsLog::IsDepsEntryLiveFor(Node* node) { + // Skip entries that don't have in-edges or whose edges don't have a + // "deps" attribute. They were in the deps log from previous builds, but + // the the files they were for were removed from the build and their deps + // entries are no longer needed. + // (Without the check for "deps", a chain of two or more nodes that each + // had deps wouldn't be collected in a single recompaction.) + return node->in_edge() && !node->in_edge()->GetBinding("deps").empty(); +} + bool DepsLog::UpdateDeps(int out_id, Deps* deps) { if (out_id >= (int)deps_.size()) deps_.resize(out_id + 1); |