summaryrefslogtreecommitdiffstats
path: root/src/deps_log.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-04-30 15:44:25 (GMT)
committerNico Weber <nicolasweber@gmx.de>2013-04-30 15:44:25 (GMT)
commit20942b8cf86da96eb4288138fba72c2609cfd54d (patch)
tree1a74d5aac1c679d712a7a444167dcebad004b447 /src/deps_log.cc
parent8d03d2cf7e572b65cd242a44081b514338e4fd6b (diff)
downloadNinja-20942b8cf86da96eb4288138fba72c2609cfd54d.zip
Ninja-20942b8cf86da96eb4288138fba72c2609cfd54d.tar.gz
Ninja-20942b8cf86da96eb4288138fba72c2609cfd54d.tar.bz2
Move updating DepsLog's deps_ array into its own function.
No functionality change.
Diffstat (limited to 'src/deps_log.cc')
-rw-r--r--src/deps_log.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/deps_log.cc b/src/deps_log.cc
index c2587af..8d90765 100644
--- a/src/deps_log.cc
+++ b/src/deps_log.cc
@@ -186,13 +186,8 @@ bool DepsLog::Load(const string& path, State* state, string* err) {
deps->nodes[i] = nodes_[deps_data[i]];
}
- if (out_id >= (int)deps_.size())
- deps_.resize(out_id + 1);
- if (deps_[out_id]) {
+ if (UpdateDeps(out_id, deps))
++dead_record_count_;
- delete deps_[out_id];
- }
- deps_[out_id] = deps;
} else {
StringPiece path(buf, size);
Node* node = state->GetNode(path);
@@ -281,6 +276,17 @@ bool DepsLog::Recompact(const string& path, string* err) {
return true;
}
+bool DepsLog::UpdateDeps(int out_id, Deps* deps) {
+ if (out_id >= (int)deps_.size())
+ deps_.resize(out_id + 1);
+
+ bool delete_old = deps_[out_id] != NULL;
+ if (delete_old)
+ delete deps_[out_id];
+ deps_[out_id] = deps;
+ return delete_old;
+}
+
bool DepsLog::RecordId(Node* node) {
uint16_t size = (uint16_t)node->path().size();
fwrite(&size, 2, 1, file_);