From 7b3afa9258e58a57ffbeb395d445811f92616ae9 Mon Sep 17 00:00:00 2001 From: Aaron Dierking Date: Tue, 29 May 2018 16:53:53 -0700 Subject: [PATCH] Avoid endl when writing symbol files endl flushes output after each line. Using "\n" instead significantly improves I/O efficiency. Change-Id: If6a5549fc3613ca3a7c9a71838ec36c5b7a20580 Reviewed-on: https://chromium-review.googlesource.com/1077626 Reviewed-by: Ivan Penkov Reviewed-by: Lei Zhang --- src/common/module.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/common/module.cc b/src/common/module.cc index b5fcb623..13c46475 100644 --- a/src/common/module.cc +++ b/src/common/module.cc @@ -44,7 +44,6 @@ namespace google_breakpad { using std::dec; -using std::endl; using std::hex; @@ -233,12 +232,12 @@ bool Module::WriteRuleMap(const RuleMap &rule_map, std::ostream &stream) { bool Module::Write(std::ostream &stream, SymbolData symbol_data) { stream << "MODULE " << os_ << " " << architecture_ << " " - << id_ << " " << name_ << endl; + << id_ << " " << name_ << "\n"; if (!stream.good()) return ReportError(); if (!code_id_.empty()) { - stream << "INFO CODE_ID " << code_id_ << endl; + stream << "INFO CODE_ID " << code_id_ << "\n"; } if (symbol_data != ONLY_CFI) { @@ -249,7 +248,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { file_it != files_.end(); ++file_it) { File *file = file_it->second; if (file->source_id >= 0) { - stream << "FILE " << file->source_id << " " << file->name << endl; + stream << "FILE " << file->source_id << " " << file->name << "\n"; if (!stream.good()) return ReportError(); } @@ -263,7 +262,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { << (func->address - load_address_) << " " << func->size << " " << func->parameter_size << " " - << func->name << dec << endl; + << func->name << dec << "\n"; if (!stream.good()) return ReportError(); @@ -274,7 +273,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { << line_it->size << " " << dec << line_it->number << " " - << line_it->file->source_id << endl; + << line_it->file->source_id << "\n"; if (!stream.good()) return ReportError(); } @@ -286,7 +285,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { Extern *ext = *extern_it; stream << "PUBLIC " << hex << (ext->address - load_address_) << " 0 " - << ext->name << dec << endl; + << ext->name << dec << "\n"; } } @@ -303,7 +302,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { || !WriteRuleMap(entry->initial_rules, stream)) return ReportError(); - stream << endl; + stream << "\n"; // Write out this entry's delta rules as 'STACK CFI' records. for (RuleChangeMap::const_iterator delta_it = entry->rule_changes.begin(); @@ -314,7 +313,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { || !WriteRuleMap(delta_it->second, stream)) return ReportError(); - stream << endl; + stream << "\n"; } } }