diff options
author | Lioncash <mathew1800@gmail.com> | 2018-10-04 23:55:50 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-10-04 23:55:53 -0400 |
commit | 6f168262605d7979d8069cd9dad21932a522263d (patch) | |
tree | 79f732b0a01deca032c6d1cf6ab408c454c08037 /src/common/logging/text_formatter.cpp | |
parent | bc679c9b8c05d3db46da8cef77e729b31c6dbff5 (diff) |
text_formatter: Avoid unnecessary string temporary creation in PrintMessage()
operator+ for std::string creates an entirely new string, which is kind
of unnecessary here if we just want to append a null terminator to the
existing one.
Reduces the total amount of potential allocations that need to be done
in the logging path.
Diffstat (limited to 'src/common/logging/text_formatter.cpp')
-rw-r--r-- | src/common/logging/text_formatter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 05437c137d..6a0605c636 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -31,7 +31,7 @@ std::string FormatLogMessage(const Entry& entry) { } void PrintMessage(const Entry& entry) { - auto str = FormatLogMessage(entry) + '\n'; + const auto str = FormatLogMessage(entry).append(1, '\n'); fputs(str.c_str(), stderr); } |