Replace std::endl with '\n'.

std::endl forces a flush, so writing \n is generally preferred for
performance reasons.

Change-Id: If700ede40a3fd543743ab6d1c4005f486a6a6964
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/27660
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Commit-Queue: Matt Stark <msta@google.com>
diff --git a/src/base/logging.cc b/src/base/logging.cc
index 0fb393a..4c769ff 100644
--- a/src/base/logging.cc
+++ b/src/base/logging.cc
@@ -172,9 +172,9 @@
 
 LogMessage::~LogMessage() {
   if (severity_ == LOG_FATAL) {
-    stream_ << std::endl;  // Newline to separate from log message.
+    stream_ << '\n';  // Newline to separate from log message.
   }
-  stream_ << std::endl;
+  stream_ << '\n';
   std::string str_newline(stream_.str());
 
 #if defined(OS_WIN)
diff --git a/src/gn/eclipse_writer.cc b/src/gn/eclipse_writer.cc
index 0067f6d..32cdaf7 100644
--- a/src/gn/eclipse_writer.cc
+++ b/src/gn/eclipse_writer.cc
@@ -119,7 +119,7 @@
 }
 
 void EclipseWriter::WriteCDTSettings() {
-  out_ << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
+  out_ << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
   XmlElementWriter cdt_properties_element(out_, "cdtprojectproperties",
                                           XmlAttributes());
 
diff --git a/src/gn/ninja_action_target_writer.cc b/src/gn/ninja_action_target_writer.cc
index 0d01d07..1196361 100644
--- a/src/gn/ninja_action_target_writer.cc
+++ b/src/gn/ninja_action_target_writer.cc
@@ -78,7 +78,7 @@
   std::vector<OutputFile> input_deps = stamp_deps.implicit;
   input_deps.insert(input_deps.end(), stamp_deps.order_only.begin(),
                     stamp_deps.order_only.end());
-  out_ << std::endl;
+  out_ << '\n';
 
   // Collects all output files for writing below.
   std::vector<OutputFile> output_files;
@@ -112,7 +112,7 @@
     }
 
     WriteValidations();
-    out_ << std::endl;
+    out_ << '\n';
 
     if (target_->action_values().has_depfile()) {
       WriteDepfile(SourceFile());
@@ -124,10 +124,10 @@
       out_ << "  pool = ";
       out_ << target_->pool().ptr->GetNinjaName(
           settings_->default_toolchain_label());
-      out_ << std::endl;
+      out_ << '\n';
     }
   }
-  out_ << std::endl;
+  out_ << '\n';
 
   // Write the phony, which doesn't need to depend on the data deps because they
   // have been added as order-only deps of the action output itself.
@@ -152,7 +152,7 @@
   EscapeOptions args_escape_options;
   args_escape_options.mode = ESCAPE_NINJA_COMMAND;
 
-  out_ << "rule " << custom_rule_name << std::endl;
+  out_ << "rule " << custom_rule_name << '\n';
 
   if (target_->action_values().uses_rsp_file()) {
     // Needs a response file. The unique_name part is for action_foreach so
@@ -163,7 +163,7 @@
     if (!target_->sources().empty())
       rspfile += ".$unique_name";
     rspfile += ".rsp";
-    out_ << "  rspfile = " << rspfile << std::endl;
+    out_ << "  rspfile = " << rspfile << '\n';
 
     // Response file contents.
     out_ << "  rspfile_content =";
@@ -173,7 +173,7 @@
       SubstitutionWriter::WriteWithNinjaVariables(arg, args_escape_options,
                                                   out_);
     }
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   // The command line requires shell escaping to properly handle filenames
@@ -190,19 +190,19 @@
     out_ << " ";
     SubstitutionWriter::WriteWithNinjaVariables(arg, args_escape_options, out_);
   }
-  out_ << std::endl;
+  out_ << '\n';
   auto mnemonic = target_->action_values().mnemonic();
   if (mnemonic.empty())
     mnemonic = "ACTION";
-  out_ << "  description = " << mnemonic << " " << target_label << std::endl;
-  out_ << "  restat = 1" << std::endl;
+  out_ << "  description = " << mnemonic << " " << target_label << '\n';
+  out_ << "  restat = 1\n";
   const Tool* tool =
       target_->toolchain()->GetTool(GeneralTool::kGeneralToolAction);
   if (tool && tool->pool().ptr) {
     out_ << "  pool = ";
     out_ << tool->pool().ptr->GetNinjaName(
         settings_->default_toolchain_label());
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   return custom_rule_name;
@@ -241,11 +241,11 @@
       path_output_.WriteFiles(out_, order_only_deps);
     }
     WriteValidations();
-    out_ << std::endl;
+    out_ << '\n';
 
     // Response files require a unique name be defined.
     if (target_->action_values().uses_rsp_file())
-      out_ << "  unique_name = " << i << std::endl;
+      out_ << "  unique_name = " << i << '\n';
 
     // The required types is the union of the args and response file. This
     // might theoretically duplicate a definition if the same substitution is
@@ -269,7 +269,7 @@
       out_ << "  pool = ";
       out_ << target_->pool().ptr->GetNinjaName(
           settings_->default_toolchain_label());
-      out_ << std::endl;
+      out_ << '\n';
     }
   }
 }
@@ -295,14 +295,14 @@
       out_,
       SubstitutionWriter::ApplyPatternToSourceAsOutputFile(
           target_, settings_, target_->action_values().depfile(), source));
-  out_ << std::endl;
+  out_ << '\n';
   // Using "deps = gcc" allows Ninja to read and store the depfile content in
   // its internal database which improves performance, especially for large
   // depfiles. The use of this feature with depfiles that contain multiple
   // outputs require Ninja version 1.9.0 or newer.
   if (settings_->build_settings()->ninja_required_version() >=
       Version{1, 9, 0}) {
-    out_ << "  deps = gcc" << std::endl;
+    out_ << "  deps = gcc\n";
   }
 }
 
diff --git a/src/gn/ninja_binary_target_writer.cc b/src/gn/ninja_binary_target_writer.cc
index 6461102..c8ee83e 100644
--- a/src/gn/ninja_binary_target_writer.cc
+++ b/src/gn/ninja_binary_target_writer.cc
@@ -217,7 +217,7 @@
     path_output_.WriteFile(out_, *input);
   }
 
-  out_ << std::endl;
+  out_ << '\n';
   return {stamp_or_phony};
 }
 
@@ -399,18 +399,18 @@
     path_output_.WriteFiles(out_, order_only_deps);
   }
   WriteValidations();
-  out_ << std::endl;
+  out_ << '\n';
 
   if (!sources.empty() && can_write_source_info) {
     out_ << "  " << "source_file_part = " << sources[0].GetName();
-    out_ << std::endl;
+    out_ << '\n';
     out_ << "  " << "source_name_part = "
          << FindFilenameNoExtension(&sources[0].value());
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   if (restat_output_allowed) {
-    out_ << "  restat = 1" << std::endl;
+    out_ << "  restat = 1\n";
   }
 }
 
@@ -540,7 +540,7 @@
     out << "  pool = ";
     out << target_->pool().ptr->GetNinjaName(
         settings_->default_toolchain_label());
-    out << std::endl;
+    out << '\n';
   }
 }
 
diff --git a/src/gn/ninja_build_writer.cc b/src/gn/ninja_build_writer.cc
index 12e323f..591e4b9 100644
--- a/src/gn/ninja_build_writer.cc
+++ b/src/gn/ninja_build_writer.cc
@@ -380,7 +380,7 @@
 
   sorter.IterateOver(item_callback);
 
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaBuildWriter::WriteAllPools() {
@@ -415,9 +415,9 @@
     std::string name = pool_name(pool);
     if (name == "console")
       continue;
-    out_ << "pool " << name << std::endl
-         << "  depth = " << pool->depth() << std::endl
-         << std::endl;
+    out_ << "pool " << name << '\n'
+         << "  depth = " << pool->depth() << '\n'
+         << '\n';
   }
 }
 
@@ -453,11 +453,11 @@
 
     out_ << "subninja ";
     path_output_.WriteFile(out_, subninja);
-    out_ << std::endl;
+    out_ << '\n';
     previous_subninja = subninja;
     previous_toolchain = pair.second;
   }
-  out_ << std::endl;
+  out_ << '\n';
   return true;
 }
 
@@ -677,22 +677,22 @@
       }
     }
   }
-  out_ << std::endl;
+  out_ << '\n';
 
   if (default_target) {
     // Use the short name when available
     if (written_rules.find(StringAtom("default")) != written_rules.end()) {
-      out_ << "\ndefault default" << std::endl;
+      out_ << "\ndefault default\n";
     } else if (default_target->has_dependency_output()) {
       // If the default target does not have a dependency output file or phony,
       // then the target specified as default is a no-op. We omit the default
       // statement entirely to avoid ninja runtime failure.
       out_ << "\ndefault ";
       path_output_.WriteFile(out_, default_target->dependency_output());
-      out_ << std::endl;
+      out_ << '\n';
     }
   } else if (!default_toolchain_targets_.empty()) {
-    out_ << "\ndefault all" << std::endl;
+    out_ << "\ndefault all\n";
   }
 
   return true;
@@ -713,5 +713,5 @@
   if (target->has_dependency_output()) {
     path_output_.WriteFile(out_, target->dependency_output());
   }
-  out_ << std::endl;
+  out_ << '\n';
 }
diff --git a/src/gn/ninja_c_binary_target_writer.cc b/src/gn/ninja_c_binary_target_writer.cc
index a56f587..7775e8f 100644
--- a/src/gn/ninja_c_binary_target_writer.cc
+++ b/src/gn/ninja_c_binary_target_writer.cc
@@ -202,7 +202,7 @@
     EscapeOptions options;
     options.mode = ESCAPE_NINJA;
     EscapeStringToStream(out_, target_->module_name(), options);
-    out_ << std::endl;
+    out_ << '\n';
   }
 }
 
@@ -219,7 +219,7 @@
       module_dep.Write(out_, path_output_, include_self);
     }
 
-    out_ << std::endl;
+    out_ << '\n';
   }
 }
 
@@ -341,7 +341,7 @@
 
   // Write two blank lines to help separate the PCH build lines from the
   // regular source build lines.
-  out_ << std::endl << std::endl;
+  out_ << "\n\n";
 }
 
 void NinjaCBinaryTargetWriter::WriteWindowsPCHCommand(
@@ -377,7 +377,7 @@
 
   // Write two blank lines to help separate the PCH build lines from the
   // regular source build lines.
-  out_ << std::endl << std::endl;
+  out_ << "\n\n";
 }
 
 void NinjaCBinaryTargetWriter::WriteSources(
@@ -493,7 +493,7 @@
     }
   }
 
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaCBinaryTargetWriter::WriteSwiftSources(
@@ -530,7 +530,7 @@
                          /*can_write_source_info=*/false,
                          /*restat_output_allowed=*/true);
 
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaCBinaryTargetWriter::WriteSourceSetStamp(
@@ -577,7 +577,7 @@
     out_ << " ||";
     path_output_.WriteFiles(out_, order_only_deps);
   }
-  out_ << std::endl;
+  out_ << '\n';
 
   // 2. Default phony target containing all files (including additional
   // outputs). Depend on the .link target to avoid duplicating object files.
@@ -595,7 +595,7 @@
     }
   }
   path_output_.WriteFiles(out_, non_object_files);
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaCBinaryTargetWriter::WriteLinkerStuff(
@@ -736,7 +736,7 @@
   WriteValidations();
 
   // End of the link "build" line.
-  out_ << std::endl;
+  out_ << '\n';
 
   // The remaining things go in the inner scope of the link line.
   if (target_->output_type() == Target::EXECUTABLE ||
@@ -744,22 +744,22 @@
       target_->output_type() == Target::LOADABLE_MODULE) {
     out_ << "  ldflags =";
     WriteLinkerFlags(out_, tool_, optional_def_file);
-    out_ << std::endl;
+    out_ << '\n';
     out_ << "  libs =";
     WriteLibs(out_, tool_);
-    out_ << std::endl;
+    out_ << '\n';
     out_ << "  frameworks =";
     WriteFrameworks(out_, tool_);
-    out_ << std::endl;
+    out_ << '\n';
     out_ << "  swiftmodules =";
     WriteSwiftModules(out_, tool_, swiftmodules);
-    out_ << std::endl;
+    out_ << '\n';
   } else if (target_->output_type() == Target::STATIC_LIBRARY) {
     out_ << "  arflags =";
     RecursiveTargetConfigStringsToStream(kRecursiveWriterKeepDuplicates,
                                          target_, &ConfigValues::arflags,
                                          GetFlagOptions(), out_);
-    out_ << std::endl;
+    out_ << '\n';
   }
   WriteOutputSubstitutions();
   WriteLibsList("solibs", solibs);
@@ -775,7 +775,7 @@
   if (!output_extension.empty()) {
     out_ << " " << output_extension;
   }
-  out_ << std::endl;
+  out_ << '\n';
 
   const std::string output_dir = SubstitutionWriter::GetLinkerSubstitution(
       target_, tool_, &SubstitutionOutputDir);
@@ -783,7 +783,7 @@
   if (!output_dir.empty()) {
     out_ << " " << output_dir;
   }
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaCBinaryTargetWriter::WriteLibsList(
@@ -797,7 +797,7 @@
                     settings_->build_settings()->root_path_utf8(),
                     ESCAPE_NINJA_COMMAND);
   output.WriteFiles(out_, libs);
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaCBinaryTargetWriter::WriteOrderOnlyDependencies(
diff --git a/src/gn/ninja_copy_target_writer.cc b/src/gn/ninja_copy_target_writer.cc
index 16fca06..1bbf926 100644
--- a/src/gn/ninja_copy_target_writer.cc
+++ b/src/gn/ninja_copy_target_writer.cc
@@ -55,7 +55,7 @@
 
   std::vector<OutputFile> output_files;
   WriteCopyRules(&output_files);
-  out_ << std::endl;
+  out_ << '\n';
   WriteStampOrPhonyForTarget(output_files, std::vector<OutputFile>());
 }
 
@@ -129,6 +129,6 @@
       path_output_.WriteFiles(out_, order_only_deps);
     }
     WriteValidations();
-    out_ << std::endl;
+    out_ << '\n';
   }
 }
diff --git a/src/gn/ninja_create_bundle_target_writer.cc b/src/gn/ninja_create_bundle_target_writer.cc
index c91d41c..6b1c90f 100644
--- a/src/gn/ninja_create_bundle_target_writer.cc
+++ b/src/gn/ninja_create_bundle_target_writer.cc
@@ -116,7 +116,7 @@
                  target_->bundle_data().GetBundleRootDirOutput(settings_)));
   out_ << ": " << BuiltinTool::kBuiltinToolPhony << " ";
   out_ << target_->dependency_output().value();
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 std::string NinjaCreateBundleTargetWriter::WritePostProcessingRuleDefinition() {
@@ -128,7 +128,7 @@
   base::ReplaceChars(custom_rule_name, ":/()", "_", &custom_rule_name);
   custom_rule_name.append("_post_processing_rule");
 
-  out_ << "rule " << custom_rule_name << std::endl;
+  out_ << "rule " << custom_rule_name << '\n';
   out_ << "  command = ";
   path_output_.WriteFile(out_, settings_->build_settings()->python_path());
   out_ << " ";
@@ -142,10 +142,10 @@
     out_ << " ";
     SubstitutionWriter::WriteWithNinjaVariables(arg, args_escape_options, out_);
   }
-  out_ << std::endl;
-  out_ << "  description = POST PROCESSING " << target_label << std::endl;
-  out_ << "  restat = 1" << std::endl;
-  out_ << std::endl;
+  out_ << '\n';
+  out_ << "  description = POST PROCESSING " << target_label << '\n';
+  out_ << "  restat = 1\n";
+  out_ << '\n';
 
   WritePostProcessingManifestFile();
   return custom_rule_name;
@@ -223,7 +223,7 @@
       path_output_.WriteFiles(out_, order_only_deps);
     }
 
-    out_ << std::endl;
+    out_ << '\n';
   }
 }
 
@@ -269,7 +269,7 @@
       out_ << " ||";
       path_output_.WriteFiles(out_, order_only_deps);
     }
-    out_ << std::endl;
+    out_ << '\n';
     return;
   }
 
@@ -307,15 +307,14 @@
     path_output_.WriteFiles(out_, order_only_deps);
   }
 
-  out_ << std::endl;
+  out_ << '\n';
 
-  out_ << "  product_type = " << target_->bundle_data().product_type()
-       << std::endl;
+  out_ << "  product_type = " << target_->bundle_data().product_type() << '\n';
 
   if (partial_info_plist != OutputFile()) {
     out_ << "  partial_info_plist = ";
     path_output_.WriteFile(out_, partial_info_plist);
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   const std::vector<SubstitutionPattern>& flags =
@@ -329,7 +328,7 @@
       SubstitutionWriter::WriteWithNinjaVariables(flag, args_escape_options,
                                                   out_);
     }
-    out_ << std::endl;
+    out_ << '\n';
   }
 }
 
@@ -368,7 +367,7 @@
       path_output_.WriteFile(out_, target->dependency_output());
     }
   }
-  out_ << std::endl;
+  out_ << '\n';
   return xcassets_input_stamp_or_phony;
 }
 
@@ -400,7 +399,7 @@
   out_ << ": " << post_processing_rule_name;
   out_ << " | ";
   path_output_.WriteFile(out_, post_processing_input_stamp_file);
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 OutputFile
@@ -460,6 +459,6 @@
     out_ << " ||";
     path_output_.WriteFiles(out_, order_only_deps);
   }
-  out_ << std::endl;
+  out_ << '\n';
   return stamp_or_phony;
 }
diff --git a/src/gn/ninja_rust_binary_target_writer.cc b/src/gn/ninja_rust_binary_target_writer.cc
index 9767144..674a008 100644
--- a/src/gn/ninja_rust_binary_target_writer.cc
+++ b/src/gn/ninja_rust_binary_target_writer.cc
@@ -33,7 +33,7 @@
               std::ostream& out) {
   out << name << " = ";
   EscapeStringToStream(out, value, opts);
-  out << std::endl;
+  out << '\n';
 }
 
 void WriteCrateVars(const Target* target,
@@ -346,7 +346,7 @@
     out_ << " ";
     path_output_.WriteFile(out_, OutputFile(settings_->build_settings(), data));
   }
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaRustBinaryTargetWriter::WriteExternsAndDeps(
@@ -434,7 +434,7 @@
     }
   }
 
-  out_ << std::endl;
+  out_ << '\n';
   out_ << "  rustdeps =";
 
   for (const SourceDir& dir : private_extern_dirs) {
@@ -466,11 +466,11 @@
   WriteFrameworks(out_, tool_);
   WriteSwiftModules(out_, tool_, swiftmodules);
 
-  out_ << std::endl;
+  out_ << '\n';
   out_ << "  ldflags =";
   // If rustc will invoke a linker, linker flags need to be forwarded through to
   // the linker.
   WriteCustomLinkerFlags(out_, tool_);
 
-  out_ << std::endl;
+  out_ << '\n';
 }
diff --git a/src/gn/ninja_target_command_util.cc b/src/gn/ninja_target_command_util.cc
index 713af4a..456b6b8 100644
--- a/src/gn/ninja_target_command_util.cc
+++ b/src/gn/ninja_target_command_util.cc
@@ -97,7 +97,7 @@
   }
 
   if (write_substitution)
-    out << std::endl;
+    out << '\n';
 }
 
 void GetPCHOutputFiles(const Target* target,
diff --git a/src/gn/ninja_target_writer.cc b/src/gn/ninja_target_writer.cc
index 5e9c136..f2536f1 100644
--- a/src/gn/ninja_target_writer.cc
+++ b/src/gn/ninja_target_writer.cc
@@ -259,7 +259,7 @@
   }
 
   path_output.WriteFiles(out, deps);
-  out << std::endl << std::endl;
+  out << "\n\n";
 }
 
 namespace {
@@ -366,7 +366,7 @@
         << GeneralTool::kGeneralToolStamp;
   }
   path_output.WriteFiles(out, deps);
-  out << std::endl;
+  out << '\n';
 }
 
 void NinjaTargetWriter::WriteEscapedSubstitution(const Substitution* type) {
@@ -376,7 +376,7 @@
   out_ << type->ninja_name << " = ";
   EscapeStringToStream(
       out_, SubstitutionWriter::GetTargetSubstitution(target_, type), opts);
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaTargetWriter::WriteSharedVars(const SubstitutionBits& bits) {
@@ -433,7 +433,7 @@
   // If we wrote any vars, separate them from the rest of the file that follows
   // with a blank line.
   if (written_anything)
-    out_ << std::endl;
+    out_ << '\n';
 }
 
 void NinjaTargetWriter::WriteCCompilerVars(const SubstitutionBits& bits,
@@ -447,7 +447,7 @@
     RecursiveTargetConfigToStream<std::string>(kRecursiveWriterSkipDuplicates,
                                                target_, &ConfigValues::defines,
                                                DefineWriter(), out_);
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   // Framework search path.
@@ -465,7 +465,7 @@
         FrameworkDirsWriter(framework_dirs_output,
                             tool->framework_dir_switch()),
         out_);
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   // Include directories.
@@ -479,7 +479,7 @@
     RecursiveTargetConfigToStream<SourceDir>(
         kRecursiveWriterSkipDuplicates, target_, &ConfigValues::include_dirs,
         IncludeWriter(include_path_output), out_);
-    out_ << std::endl;
+    out_ << '\n';
   }
 
   bool has_precompiled_headers =
@@ -545,7 +545,7 @@
         out_ << "  ";
       out_ << CSubstitutionSwiftModuleName.ninja_name << " = ";
       EscapeStringToStream(out_, target_->swift_values().module_name(), opts);
-      out_ << std::endl;
+      out_ << '\n';
     }
 
     if (bits.used.count(&CSubstitutionSwiftBridgeHeader)) {
@@ -557,7 +557,7 @@
       } else {
         out_ << R"("")";
       }
-      out_ << std::endl;
+      out_ << '\n';
     }
 
     if (bits.used.count(&CSubstitutionSwiftModuleDirs)) {
@@ -577,7 +577,7 @@
       for (const SourceDir& swiftmodule_dir : swiftmodule_dirs) {
         swiftmodule_path_writer(swiftmodule_dir, out_);
       }
-      out_ << std::endl;
+      out_ << '\n';
     }
 
     WriteOneFlag(kRecursiveWriterKeepDuplicates, target_,
@@ -875,7 +875,7 @@
     path_output_.WriteFiles(out_, order_only_deps);
   }
   WriteValidations();
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaTargetWriter::WriteValidations() {
diff --git a/src/gn/ninja_toolchain_writer.cc b/src/gn/ninja_toolchain_writer.cc
index fb04b95..38ee39d 100644
--- a/src/gn/ninja_toolchain_writer.cc
+++ b/src/gn/ninja_toolchain_writer.cc
@@ -50,7 +50,7 @@
     }
     WriteToolRule(tool.second.get(), rule_prefix);
   }
-  out_ << std::endl;
+  out_ << '\n';
 
   for (const auto& pair : rules)
     out_ << pair.second;
@@ -81,7 +81,7 @@
 
 void NinjaToolchainWriter::WriteToolRule(Tool* tool,
                                          const std::string& rule_prefix) {
-  out_ << "rule " << rule_prefix << tool->name() << std::endl;
+  out_ << "rule " << rule_prefix << tool->name() << '\n';
 
   // Rules explicitly include shell commands, so don't try to escape.
   EscapeOptions options;
@@ -99,26 +99,26 @@
       // GCC-style deps require a depfile.
       if (!c_tool->depfile().empty()) {
         WriteRulePattern("depfile", tool->depfile(), options);
-        out_ << kIndent << "deps = gcc" << std::endl;
+        out_ << kIndent << "deps = gcc\n";
       }
     } else if (c_tool->depsformat() == CTool::DEPS_MSVC) {
       // MSVC deps don't have a depfile.
-      out_ << kIndent << "deps = msvc" << std::endl;
+      out_ << kIndent << "deps = msvc\n";
     }
   } else if (!tool->depfile().empty()) {
     WriteRulePattern("depfile", tool->depfile(), options);
-    out_ << kIndent << "deps = gcc" << std::endl;
+    out_ << kIndent << "deps = gcc\n";
   }
 
   // Use pool is specified.
   if (tool->pool().ptr) {
     std::string pool_name =
         tool->pool().ptr->GetNinjaName(settings_->default_toolchain_label());
-    out_ << kIndent << "pool = " << pool_name << std::endl;
+    out_ << kIndent << "pool = " << pool_name << '\n';
   }
 
   if (tool->restat())
-    out_ << kIndent << "restat = 1" << std::endl;
+    out_ << kIndent << "restat = 1\n";
 
   // If the size is exactly 1, we don't need a phony rule, since we just write
   // the input file directly in the build action.
@@ -133,7 +133,7 @@
       path_output_.WriteFile(out_,
                              OutputFile(settings_->build_settings(), input));
     }
-    out_ << std::endl;
+    out_ << '\n';
   }
 }
 
@@ -144,7 +144,7 @@
     return;
   out_ << kIndent << name << " = ";
   SubstitutionWriter::WriteWithNinjaVariables(pattern, options, out_);
-  out_ << std::endl;
+  out_ << '\n';
 }
 
 void NinjaToolchainWriter::WriteCommandRulePattern(
@@ -157,5 +157,5 @@
   if (!launcher.empty())
     out_ << launcher << " ";
   SubstitutionWriter::WriteWithNinjaVariables(command, options, out_);
-  out_ << std::endl;
+  out_ << '\n';
 }
diff --git a/src/gn/parser.cc b/src/gn/parser.cc
index 96739a5..e4105bb 100644
--- a/src/gn/parser.cc
+++ b/src/gn/parser.cc
@@ -904,15 +904,15 @@
   if (node_type == "ACCESSOR") {
     // AccessorNode is a bit special, in that it holds a Token, not a ParseNode
     // for the base.
-    os << IndentFor(indent_level) << node_type << std::endl;
+    os << IndentFor(indent_level) << node_type << '\n';
     os << IndentFor(indent_level + 1) << node.FindKey("value")->GetString()
-       << std::endl;
+       << '\n';
   } else {
     os << IndentFor(indent_level) << node_type;
     if (node.FindKey("value")) {
       os << "(" << node.FindKey("value")->GetString() << ")";
     }
-    os << std::endl;
+    os << '\n';
   }
   if (node.FindKey(kJsonBeforeComment)) {
     for (auto& v : node.FindKey(kJsonBeforeComment)->GetList()) {
diff --git a/src/gn/qt_creator_writer.cc b/src/gn/qt_creator_writer.cc
index 6ea1af5..915c07c 100644
--- a/src/gn/qt_creator_writer.cc
+++ b/src/gn/qt_creator_writer.cc
@@ -273,7 +273,7 @@
   StringOutputBuffer storage;
   std::ostream output(&storage);
   for (const std::string& item : items)
-    output << item << std::endl;
+    output << item << '\n';
   storage.WriteToFileIfChanged(file_path, &err_);
 }
 
diff --git a/src/gn/runtime_deps.cc b/src/gn/runtime_deps.cc
index 997f64f..a7a9151 100644
--- a/src/gn/runtime_deps.cc
+++ b/src/gn/runtime_deps.cc
@@ -122,7 +122,7 @@
   // considered data deps.
   auto on_file = [&out](std::string_view output_file,
                         const Target* target) -> void {
-    out << output_file << std::endl;
+    out << output_file << '\n';
   };
   RecursiveCollectRuntimeDeps(target, false, on_file, &seen_targets);
 }
diff --git a/src/gn/substitution_writer.cc b/src/gn/substitution_writer.cc
index b6d0c48..f021b66 100644
--- a/src/gn/substitution_writer.cc
+++ b/src/gn/substitution_writer.cc
@@ -335,7 +335,7 @@
           GetSourceSubstitution(target, settings, source, type, OUTPUT_RELATIVE,
                                 settings->build_settings()->build_dir()),
           escape_options);
-      out << std::endl;
+      out << '\n';
     }
   }
 }
diff --git a/src/gn/trace.cc b/src/gn/trace.cc
index c3775a6..77093aa 100644
--- a/src/gn/trace.cc
+++ b/src/gn/trace.cc
@@ -78,7 +78,7 @@
   std::sort(loads.begin(), loads.end(), &DurationGreater);
   for (auto* load : loads) {
     out << base::StringPrintf(" %8.2f  ", load->delta().InMillisecondsF());
-    out << load->name() << std::endl;
+    out << load->name() << '\n';
   }
 }
 
@@ -102,7 +102,7 @@
 
   for (const auto& cur : sorted) {
     out << base::StringPrintf(" %8.2f  %d  ", cur.total_duration, cur.count);
-    out << *cur.name_ptr << std::endl;
+    out << *cur.name_ptr << '\n';
   }
 }
 
@@ -226,11 +226,11 @@
 
   std::ostringstream out;
   SummarizeParses(parses, out);
-  out << std::endl;
+  out << '\n';
   SummarizeFileExecs(file_execs, out);
-  out << std::endl;
+  out << '\n';
   SummarizeScriptExecs(script_execs, out);
-  out << std::endl;
+  out << '\n';
 
   // Generally there will only be one header check, but it's theoretically
   // possible for more than one to run if more than one build is going in
diff --git a/src/gn/visual_studio_writer.cc b/src/gn/visual_studio_writer.cc
index 13e54d4..1326bf0 100644
--- a/src/gn/visual_studio_writer.cc
+++ b/src/gn/visual_studio_writer.cc
@@ -463,7 +463,7 @@
                          build_settings_->root_path_utf8(),
                          EscapingMode::ESCAPE_NONE);
 
-  out << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
+  out << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   XmlElementWriter project(
       out, "Project",
       XmlAttributes("DefaultTargets", "Build")
@@ -688,7 +688,7 @@
     std::ostream& out,
     const Target* target,
     const SourceFileCompileTypePairs& source_types) {
-  out << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
+  out << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   XmlElementWriter project(
       out, "Project",
       XmlAttributes("ToolsVersion", "4.0")
@@ -768,64 +768,61 @@
 void VisualStudioWriter::WriteSolutionFileContents(
     std::ostream& out,
     const base::FilePath& solution_dir_path) {
-  out << "Microsoft Visual Studio Solution File, Format Version 12.00"
-      << std::endl;
-  out << "# " << version_string_ << std::endl;
+  out << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+  out << "# " << version_string_ << '\n';
 
   SourceDir solution_dir(FilePathToUTF8(solution_dir_path));
   for (const std::unique_ptr<SolutionEntry>& folder : folders_) {
     out << "Project(\"" << kGuidTypeFolder << "\") = \"(" << folder->name
         << ")\", \"" << RebasePath(folder->path, solution_dir) << "\", \""
-        << folder->guid << "\"" << std::endl;
-    out << "EndProject" << std::endl;
+        << folder->guid << "\"\n";
+    out << "EndProject\n";
   }
 
   for (const std::unique_ptr<SolutionProject>& project : projects_) {
     out << "Project(\"" << kGuidTypeProject << "\") = \"" << project->name
         << "\", \"" << RebasePath(project->path, solution_dir) << "\", \""
-        << project->guid << "\"" << std::endl;
-    out << "EndProject" << std::endl;
+        << project->guid << "\"\n";
+    out << "EndProject\n";
   }
 
-  out << "Global" << std::endl;
+  out << "Global\n";
 
-  out << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"
-      << std::endl;
+  out << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
   const std::string config_mode_prefix = std::string(kConfigurationName) + '|';
   const std::string config_mode = config_mode_prefix + config_platform_;
-  out << "\t\t" << config_mode << " = " << config_mode << std::endl;
-  out << "\tEndGlobalSection" << std::endl;
+  out << "\t\t" << config_mode << " = " << config_mode << '\n';
+  out << "\tEndGlobalSection\n";
 
-  out << "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"
-      << std::endl;
+  out << "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n";
   for (const std::unique_ptr<SolutionProject>& project : projects_) {
     const std::string project_config_mode =
         config_mode_prefix + project->config_platform;
     out << "\t\t" << project->guid << '.' << config_mode
-        << ".ActiveCfg = " << project_config_mode << std::endl;
+        << ".ActiveCfg = " << project_config_mode << '\n';
     out << "\t\t" << project->guid << '.' << config_mode
-        << ".Build.0 = " << project_config_mode << std::endl;
+        << ".Build.0 = " << project_config_mode << '\n';
   }
-  out << "\tEndGlobalSection" << std::endl;
+  out << "\tEndGlobalSection\n";
 
-  out << "\tGlobalSection(SolutionProperties) = preSolution" << std::endl;
-  out << "\t\tHideSolutionNode = FALSE" << std::endl;
-  out << "\tEndGlobalSection" << std::endl;
+  out << "\tGlobalSection(SolutionProperties) = preSolution\n";
+  out << "\t\tHideSolutionNode = FALSE\n";
+  out << "\tEndGlobalSection\n";
 
-  out << "\tGlobalSection(NestedProjects) = preSolution" << std::endl;
+  out << "\tGlobalSection(NestedProjects) = preSolution\n";
   for (const std::unique_ptr<SolutionEntry>& folder : folders_) {
     if (folder->parent_folder) {
       out << "\t\t" << folder->guid << " = " << folder->parent_folder->guid
-          << std::endl;
+          << '\n';
     }
   }
   for (const std::unique_ptr<SolutionProject>& project : projects_) {
     out << "\t\t" << project->guid << " = " << project->parent_folder->guid
-        << std::endl;
+        << '\n';
   }
-  out << "\tEndGlobalSection" << std::endl;
+  out << "\tEndGlobalSection\n";
 
-  out << "EndGlobal" << std::endl;
+  out << "EndGlobal\n";
 }
 
 void VisualStudioWriter::ResolveSolutionFolders() {
diff --git a/src/gn/xml_element_writer.cc b/src/gn/xml_element_writer.cc
index f888915..60174cb 100644
--- a/src/gn/xml_element_writer.cc
+++ b/src/gn/xml_element_writer.cc
@@ -42,11 +42,11 @@
   if (!opening_tag_finished_) {
     // The XML spec does not require a space before the closing slash. However,
     // Eclipse is unable to parse XML settings files if there is no space.
-    out_ << " />" << std::endl;
+    out_ << " />\n";
   } else {
     if (!one_line_)
       out_ << std::string(indent_, ' ');
-    out_ << "</" << tag_ << '>' << std::endl;
+    out_ << "</" << tag_ << ">\n";
   }
 }
 
@@ -73,7 +73,7 @@
     opening_tag_finished_ = true;
 
     if (start_new_line && one_line_) {
-      out_ << std::endl;
+      out_ << '\n';
       one_line_ = false;
     }
   }