lg2: reduce string_view for size optimize
There were a few places where string_view's were used for simplicity,
but as a result the compiler ends up instantiating temporary
string_view objects, which makes the generated code larger. Switch
to 'const char*' instead and avoid needless string_view constructions.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia29470e8db0f1489bf7b5f6a18b1af0877d0ce72
diff --git a/lib/lg2_logger.cpp b/lib/lg2_logger.cpp
index 96e244b..ac7a75c 100644
--- a/lib/lg2_logger.cpp
+++ b/lib/lg2_logger.cpp
@@ -143,8 +143,8 @@
isatty(fileno(stderr)) ? cerr_extra_output : noop_extra_output;
// Do_log implementation.
-void do_log(level l, const std::source_location& s, const std::string_view& m,
- size_t count, ...)
+void do_log(level l, const std::source_location& s, const char* m, size_t count,
+ ...)
{
using namespace std::string_literals;
@@ -154,7 +154,7 @@
std::string message{m};
// Assign all the static fields.
- strings[pos_fmtmsg] = "LOG2_FMTMSG="s + m.data();
+ strings[pos_fmtmsg] = "LOG2_FMTMSG="s + m;
strings[pos_prio] = "PRIORITY="s + std::to_string(static_cast<uint64_t>(l));
strings[pos_file] = "CODE_FILE="s + s.file_name();
strings[pos_line] = "CODE_LINE="s + std::to_string(s.line());