From 99a72092646537992d57196e5286cc556b1437e5 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Mon, 10 Nov 2014 17:55:18 -0800 Subject: no need to save slash_bits, add comment --- src/deps_log.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/deps_log.cc b/src/deps_log.cc index 9514446..fc46497 100644 --- a/src/deps_log.cc +++ b/src/deps_log.cc @@ -30,7 +30,7 @@ // The version is stored as 4 bytes after the signature and also serves as a // byte order mark. Signature and version combined are 16 bytes long. const char kFileSignature[] = "# ninjadeps\n"; -const int kCurrentVersion = 4; +const int kCurrentVersion = 3; // Record size is currently limited to less than the full 32 bit, due to // internal buffers having to have this size. @@ -233,16 +233,19 @@ bool DepsLog::Load(const string& path, State* state, string* err) { if (!UpdateDeps(out_id, deps)) ++unique_dep_record_count; } else { - int path_size = size - 8; + int path_size = size - 4; assert(path_size > 0); // CanonicalizePath() rejects empty paths. // There can be up to 3 bytes of padding. if (buf[path_size - 1] == '\0') --path_size; if (buf[path_size - 1] == '\0') --path_size; if (buf[path_size - 1] == '\0') --path_size; StringPiece path(buf, path_size); - unsigned int slash_bits = - *reinterpret_cast(buf + size - 8); - Node* node = state->GetNode(path, slash_bits); + // It is not necessary to pass in a correct slash_bits here. It will + // either be a Node that's in the manifest (in which case it will already + // have a correct slash_bits that GetNode will look up), or it is an + // implicit dependency from a .d which does not affect the build command + // (and so need not have its slashes maintained). + Node* node = state->GetNode(path, 0); // Check that the expected index matches the actual index. This can only // happen if two ninja processes write to the same deps log concurrently. @@ -382,7 +385,7 @@ bool DepsLog::RecordId(Node* node) { int path_size = node->path().size(); int padding = (4 - path_size % 4) % 4; // Pad path to 4 byte boundary. - unsigned size = path_size + padding + 4 + 4; + unsigned size = path_size + padding + 4; if (size > kMaxRecordSize) { errno = ERANGE; return false; @@ -395,9 +398,6 @@ bool DepsLog::RecordId(Node* node) { } if (padding && fwrite("\0\0", padding, 1, file_) < 1) return false; - unsigned int slash_bits = node->slash_bits(); - if (fwrite(&slash_bits, 4, 1, file_) < 1) - return false; int id = nodes_.size(); unsigned checksum = ~(unsigned)id; if (fwrite(&checksum, 4, 1, file_) < 1) -- cgit v0.12