From 9de6eae6bbf2ccc9529cc266ceb0587b376c7e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 8 Mar 2020 14:04:20 +0100 Subject: [PATCH] ConsoleReporter no longer creates a string when writing time units This is minor perf improvement only, but it is free and trivial. --- src/catch2/reporters/catch_reporter_console.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index e091225e..f7b924ae 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -250,20 +250,20 @@ public: return static_cast(m_inNanoseconds); } } - auto unitsAsString() const -> std::string { + StringRef unitsAsString() const { switch (m_units) { case Unit::Nanoseconds: - return "ns"; + return "ns"_sr; case Unit::Microseconds: - return "us"; + return "us"_sr; case Unit::Milliseconds: - return "ms"; + return "ms"_sr; case Unit::Seconds: - return "s"; + return "s"_sr; case Unit::Minutes: - return "m"; + return "m"_sr; default: - return "** internal error **"; + return "** internal error **"_sr; } }