Skip to content

Commit

Permalink
no recompacting needed when log file is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
syntheticpp committed Jun 18, 2012
1 parent e152414 commit f9abd79
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/build_log.cc
Expand Up @@ -223,7 +223,8 @@ bool BuildLog::Load(const string& path, string* err) {
int total_entry_count = 0;

LineReader reader(file);
char* line_start, *line_end;
char* line_start = 0;
char* line_end = 0;
while (reader.ReadLine(&line_start, &line_end)) {
if (!log_version) {
log_version = 1; // Assume by default.
Expand Down Expand Up @@ -295,6 +296,11 @@ bool BuildLog::Load(const string& path, string* err) {
entry->command_hash = LogEntry::HashCommand(StringPiece(start,
end - start));
}
fclose(file);

if (!line_start) {
return true; // file was empty
}

// Decide whether it's time to rebuild the log:
// - if we're upgrading versions
Expand All @@ -308,8 +314,6 @@ bool BuildLog::Load(const string& path, string* err) {
needs_recompaction_ = true;
}

fclose(file);

return true;
}

Expand Down

0 comments on commit f9abd79

Please sign in to comment.