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 virtual void handleMessage
( AssertionInfo const& info, ( AssertionInfo const& info,
ResultWas::OfType resultType, ResultWas::OfType resultType,
StringRef message, std::string&& message,
AssertionReaction& reaction ) = 0; AssertionReaction& reaction ) = 0;
virtual void handleUnexpectedExceptionNotThrown virtual void handleUnexpectedExceptionNotThrown
( AssertionInfo const& info, ( AssertionInfo const& info,

View File

@ -28,8 +28,8 @@ namespace Catch {
void AssertionHandler::handleExpr( ITransientExpression const& expr ) { void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
} }
void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) { void AssertionHandler::handleMessage(ResultWas::OfType resultType, std::string&& message) {
m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); m_resultCapture.handleMessage( m_assertionInfo, resultType, CATCH_MOVE(message), m_reaction );
} }
auto AssertionHandler::allowThrows() const -> bool { auto AssertionHandler::allowThrows() const -> bool {

View File

@ -47,7 +47,7 @@ namespace Catch {
} }
void handleExpr( ITransientExpression const& expr ); void handleExpr( ITransientExpression const& expr );
void handleMessage(ResultWas::OfType resultType, StringRef message); void handleMessage(ResultWas::OfType resultType, std::string&& message);
void handleExceptionThrownAsExpected(); void handleExceptionThrownAsExpected();
void handleUnexpectedExceptionNotThrown(); void handleUnexpectedExceptionNotThrown();

View File

@ -632,13 +632,13 @@ namespace Catch {
void RunContext::handleMessage( void RunContext::handleMessage(
AssertionInfo const& info, AssertionInfo const& info,
ResultWas::OfType resultType, ResultWas::OfType resultType,
StringRef message, std::string&& message,
AssertionReaction& reaction AssertionReaction& reaction
) { ) {
m_lastAssertionInfo = info; m_lastAssertionInfo = info;
AssertionResultData data( resultType, LazyExpression( false ) ); AssertionResultData data( resultType, LazyExpression( false ) );
data.message = static_cast<std::string>(message); data.message = CATCH_MOVE( message );
AssertionResult assertionResult{ m_lastAssertionInfo, AssertionResult assertionResult{ m_lastAssertionInfo,
CATCH_MOVE( data ) }; CATCH_MOVE( data ) };

View File

@ -55,7 +55,7 @@ namespace Catch {
void handleMessage void handleMessage
( AssertionInfo const& info, ( AssertionInfo const& info,
ResultWas::OfType resultType, ResultWas::OfType resultType,
StringRef message, std::string&& message,
AssertionReaction& reaction ) override; AssertionReaction& reaction ) override;
void handleUnexpectedExceptionNotThrown void handleUnexpectedExceptionNotThrown
( AssertionInfo const& info, ( AssertionInfo const& info,