Skip to content

Commit

Permalink
deps: V8: stop torque updating unchanged empty files
Browse files Browse the repository at this point in the history
Make torque only write out files if the file doesn't exist or the
contents have changed.
  • Loading branch information
richardlau committed Feb 24, 2021
1 parent 76a073b commit 4067f64
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deps/v8/src/torque/utils.cc
Expand Up @@ -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 old_file = false;
if (old_contents_stream.good()) {
std::istreambuf_iterator<char> eos;
old_file = true;
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 (!old_file || old_contents != contents) {
std::ofstream new_contents_stream;
new_contents_stream.open(file_path.c_str());
new_contents_stream << contents;
Expand Down

0 comments on commit 4067f64

Please sign in to comment.