Avoid needless copy of string in runContext::handleMessage

This commit is contained in:
Martin Hořeňovský 2024-09-13 13:42:03 +02:00
parent bd70515c08
commit 412cad546a
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
5 changed files with 7 additions and 7 deletions

View File

@ -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,

View File

@ -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 {

View File

@ -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();

View File

@ -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 ) };

View File

@ -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,