summaryrefslogtreecommitdiffstats
path: root/src/build_log.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/build_log.cc')
-rw-r--r--src/build_log.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index 6b73002..6fb179a 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -54,26 +54,27 @@ uint64_t MurmurHash64A(const void* key, size_t len) {
const uint64_t m = BIG_CONSTANT(0xc6a4a7935bd1e995);
const int r = 47;
uint64_t h = seed ^ (len * m);
- const uint64_t * data = (const uint64_t *)key;
- const uint64_t * end = data + (len/8);
- while (data != end) {
- uint64_t k = *data++;
+ const unsigned char * data = (const unsigned char *)key;
+ while (len >= 8) {
+ uint64_t k;
+ memcpy(&k, data, sizeof k);
k *= m;
k ^= k >> r;
k *= m;
h ^= k;
h *= m;
+ data += 8;
+ len -= 8;
}
- const unsigned char* data2 = (const unsigned char*)data;
switch (len & 7)
{
- case 7: h ^= uint64_t(data2[6]) << 48;
- case 6: h ^= uint64_t(data2[5]) << 40;
- case 5: h ^= uint64_t(data2[4]) << 32;
- case 4: h ^= uint64_t(data2[3]) << 24;
- case 3: h ^= uint64_t(data2[2]) << 16;
- case 2: h ^= uint64_t(data2[1]) << 8;
- case 1: h ^= uint64_t(data2[0]);
+ case 7: h ^= uint64_t(data[6]) << 48;
+ case 6: h ^= uint64_t(data[5]) << 40;
+ case 5: h ^= uint64_t(data[4]) << 32;
+ case 4: h ^= uint64_t(data[3]) << 24;
+ case 3: h ^= uint64_t(data[2]) << 16;
+ case 2: h ^= uint64_t(data[1]) << 8;
+ case 1: h ^= uint64_t(data[0]);
h *= m;
};
h ^= h >> r;
@@ -109,7 +110,6 @@ BuildLog::~BuildLog() {
bool BuildLog::OpenForWrite(const string& path, string* err) {
if (needs_recompaction_) {
- Close();
if (!Recompact(path, err))
return false;
}
@@ -351,6 +351,7 @@ bool BuildLog::Recompact(const string& path, string* err) {
METRIC_RECORD(".ninja_log recompact");
printf("Recompacting log...\n");
+ Close();
string temp_path = path + ".recompact";
FILE* f = fopen(temp_path.c_str(), "wb");
if (!f) {