Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

ConsoleReporter no longer creates a string when writing time units

This is minor perf improvement only, but it is free and trivial.
Commit
9de6eae6bbf2ccc9529cc266ceb0587b376c7e0d
Author
Martin Hořeňovský ·
Parents
d1ffaf55a165

Files · Download .tar.gz

Changes

 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<double>(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;
         }
 
     }