diff options
| author | Martin Hořeňovský | 2024-09-13 13:42:03 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2024-09-13 16:39:51 +0200 |
| commit | 412cad546a89cda9eaa8ef77d8161b719182cc9e (patch) | |
| tree | dafc5cbabcf0959a882f5888f9bed060396d6ef7 /src/catch2 | |
| parent | bd70515c0831bb741eb1865e9ed31d321417d735 (diff) | |
| download | catch3-412cad546a89cda9eaa8ef77d8161b719182cc9e.tar.gz | |
Avoid needless copy of string in runContext::handleMessage
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/interfaces/catch_interfaces_capture.hpp | 2 | ||||
| -rw-r--r-- | src/catch2/internal/catch_assertion_handler.cpp | 4 | ||||
| -rw-r--r-- | src/catch2/internal/catch_assertion_handler.hpp | 2 | ||||
| -rw-r--r-- | src/catch2/internal/catch_run_context.cpp | 4 | ||||
| -rw-r--r-- | src/catch2/internal/catch_run_context.hpp | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp index a1876a4c..2b23e29a 100644 --- a/src/catch2/interfaces/catch_interfaces_capture.hpp +++ b/src/catch2/interfaces/catch_interfaces_capture.hpp @@ -77,7 +77,7 @@ namespace Catch { virtual void handleMessage ( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) = 0; virtual void handleUnexpectedExceptionNotThrown ( AssertionInfo const& info, diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp index f650a707..9a28e79c 100644 --- a/src/catch2/internal/catch_assertion_handler.cpp +++ b/src/catch2/internal/catch_assertion_handler.cpp @@ -28,8 +28,8 @@ namespace Catch { void AssertionHandler::handleExpr( ITransientExpression const& expr ) { m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); } - void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) { - m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + void AssertionHandler::handleMessage(ResultWas::OfType resultType, std::string&& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, CATCH_MOVE(message), m_reaction ); } auto AssertionHandler::allowThrows() const -> bool { diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index 01dd7801..098ed7a9 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -47,7 +47,7 @@ namespace Catch { } void handleExpr( ITransientExpression const& expr ); - void handleMessage(ResultWas::OfType resultType, StringRef message); + void handleMessage(ResultWas::OfType resultType, std::string&& message); void handleExceptionThrownAsExpected(); void handleUnexpectedExceptionNotThrown(); diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 00861968..2a102fbe 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -632,13 +632,13 @@ namespace Catch { void RunContext::handleMessage( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) { m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); - data.message = static_cast<std::string>(message); + data.message = CATCH_MOVE( message ); AssertionResult assertionResult{ m_lastAssertionInfo, CATCH_MOVE( data ) }; diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp index f7f353e2..c66fec0c 100644 --- a/src/catch2/internal/catch_run_context.hpp +++ b/src/catch2/internal/catch_run_context.hpp @@ -55,7 +55,7 @@ namespace Catch { void handleMessage ( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) override; void handleUnexpectedExceptionNotThrown ( AssertionInfo const& info, |