Commit 373f4ae7 authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[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/+/2596789Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#72053}
parent f7b60fa7
......@@ -317,13 +317,15 @@ void ReplaceFileContentsIfDifferent(const std::string& file_path,
const std::string& contents) {
std::ifstream old_contents_stream(file_path.c_str());
std::string old_contents;
bool file_exists = false;
if (old_contents_stream.good()) {
file_exists = true;
std::istreambuf_iterator<char> eos;
old_contents =
std::string(std::istreambuf_iterator<char>(old_contents_stream), eos);
old_contents_stream.close();
}
if (old_contents.length() == 0 || old_contents != contents) {
if (!file_exists || old_contents != contents) {
std::ofstream new_contents_stream;
new_contents_stream.open(file_path.c_str());
new_contents_stream << contents;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment