Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-09-13 13:42:03 +0200
committerMartin Hořeňovský2024-09-13 16:39:51 +0200
commit412cad546a89cda9eaa8ef77d8161b719182cc9e (patch)
treedafc5cbabcf0959a882f5888f9bed060396d6ef7 /src/catch2/internal
parentbd70515c0831bb741eb1865e9ed31d321417d735 (diff)
downloadcatch3-412cad546a89cda9eaa8ef77d8161b719182cc9e.tar.gz
Avoid needless copy of string in runContext::handleMessage
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_assertion_handler.cpp4
-rw-r--r--src/catch2/internal/catch_assertion_handler.hpp2
-rw-r--r--src/catch2/internal/catch_run_context.cpp4
-rw-r--r--src/catch2/internal/catch_run_context.hpp2
4 files changed, 6 insertions, 6 deletions
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,