Commit f39a6efa authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Improve logging performance.

Previously std::stringstream::str() was called twice, which generates
two distinct (but identical) strings. This CL caches the result of the
call and uses it twice.

Bug: 862725
Change-Id: I0384981a259b12d6c3ecf1420436f71e1e002fe6
Reviewed-on: https://chromium-review.googlesource.com/1134218Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574625}
parent df94a28e
......@@ -30,13 +30,14 @@ ScopedLogMessage::~ScopedLogMessage() {
if (!g_logging_enabled)
return;
const std::string string_from_stream = stream_.str();
LogBuffer::GetInstance()->AddLogMessage(LogBuffer::LogMessage(
stream_.str(), base::Time::Now(), file_, line_, severity_));
string_from_stream, base::Time::Now(), file_, line_, severity_));
// The destructor of |log_message| also creates a log for the standard logging
// system.
logging::LogMessage log_message(file_, line_, severity_);
log_message.stream() << stream_.str();
log_message.stream() << string_from_stream;
}
} // namespace proximity_auth
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