Skip to content

Commit 373f4ae

Browse files
sethbrenithCommit Bot
authored andcommitted
[torque] Don't replace unmodified empty files
To improve incremental builds. Bug: v8:7793 Change-Id: I6990a97e058d22d34acd1f609167cd30ca7518ad Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2596789 Reviewed-by: Nico Hartmann <[email protected]> Commit-Queue: Seth Brenith <[email protected]> Cr-Commit-Position: refs/heads/master@{#72053}
1 parent f7b60fa commit 373f4ae

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/torque/utils.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,15 @@ void ReplaceFileContentsIfDifferent(const std::string& file_path,
317317
const std::string& contents) {
318318
std::ifstream old_contents_stream(file_path.c_str());
319319
std::string old_contents;
320+
bool file_exists = false;
320321
if (old_contents_stream.good()) {
322+
file_exists = true;
321323
std::istreambuf_iterator<char> eos;
322324
old_contents =
323325
std::string(std::istreambuf_iterator<char>(old_contents_stream), eos);
324326
old_contents_stream.close();
325327
}
326-
if (old_contents.length() == 0 || old_contents != contents) {
328+
if (!file_exists || old_contents != contents) {
327329
std::ofstream new_contents_stream;
328330
new_contents_stream.open(file_path.c_str());
329331
new_contents_stream << contents;

0 commit comments

Comments
 (0)