From 40209d1ae0fefc6ee4144be6bcb1366ef1444506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 14 Sep 2017 20:05:25 +0200 Subject: [PATCH] Use StringRef on fatal error path So far the fatal error path only uses string literals, so this removes an allocation from that context --- include/internal/catch_interfaces_capture.h | 4 +++- include/internal/catch_run_context.cpp | 2 +- include/internal/catch_run_context.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h index d153a8bc..5b370114 100644 --- a/include/internal/catch_interfaces_capture.h +++ b/include/internal/catch_interfaces_capture.h @@ -10,6 +10,8 @@ #include +#include "catch_stringref.h" + namespace Catch { class AssertionResult; @@ -43,7 +45,7 @@ namespace Catch { virtual void exceptionEarlyReported() = 0; - virtual void handleFatalErrorCondition( std::string const& message ) = 0; + virtual void handleFatalErrorCondition( StringRef message ) = 0; virtual bool lastAssertionPassed() = 0; virtual void assertionPassed() = 0; diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp index b034ec62..11b85b24 100644 --- a/include/internal/catch_run_context.cpp +++ b/include/internal/catch_run_context.cpp @@ -208,7 +208,7 @@ namespace Catch { m_shouldReportUnexpected = false; } - void RunContext::handleFatalErrorCondition(std::string const & message) { + void RunContext::handleFatalErrorCondition( StringRef message ) { // First notify reporter that bad things happened m_reporter->fatalErrorEncountered(message); diff --git a/include/internal/catch_run_context.h b/include/internal/catch_run_context.h index 64314cb2..3f238171 100644 --- a/include/internal/catch_run_context.h +++ b/include/internal/catch_run_context.h @@ -100,7 +100,7 @@ namespace Catch { void exceptionEarlyReported() override; - void handleFatalErrorCondition(std::string const& message) override; + void handleFatalErrorCondition( StringRef message ) override; bool lastAssertionPassed() override;