mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Move AssertionResultData into AssertionResult in RunContext
When running `./tests/SelfTest -o /dev/null`, this saves 109 allocations (437167 -> 437058).
This commit is contained in:
parent
2403f5620e
commit
e5d1eb757f
@ -7,6 +7,7 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#include <catch2/catch_assertion_result.hpp>
|
#include <catch2/catch_assertion_result.hpp>
|
||||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||||
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -26,9 +27,9 @@ namespace Catch {
|
|||||||
return reconstructedExpression;
|
return reconstructedExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
|
AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData&& data )
|
||||||
: m_info( info ),
|
: m_info( info ),
|
||||||
m_resultData( data )
|
m_resultData( CATCH_MOVE(data) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Result was a success
|
// Result was a success
|
||||||
|
@ -35,7 +35,7 @@ namespace Catch {
|
|||||||
class AssertionResult {
|
class AssertionResult {
|
||||||
public:
|
public:
|
||||||
AssertionResult() = delete;
|
AssertionResult() = delete;
|
||||||
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
|
AssertionResult( AssertionInfo const& info, AssertionResultData&& data );
|
||||||
|
|
||||||
bool isOk() const;
|
bool isOk() const;
|
||||||
bool succeeded() const;
|
bool succeeded() const;
|
||||||
|
@ -428,7 +428,7 @@ namespace Catch {
|
|||||||
// Instead, fake a result data.
|
// Instead, fake a result data.
|
||||||
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );
|
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );
|
||||||
tempResult.message = static_cast<std::string>(message);
|
tempResult.message = static_cast<std::string>(message);
|
||||||
AssertionResult result(m_lastAssertionInfo, tempResult);
|
AssertionResult result(m_lastAssertionInfo, CATCH_MOVE(tempResult));
|
||||||
|
|
||||||
assertionEnded(result);
|
assertionEnded(result);
|
||||||
|
|
||||||
@ -579,7 +579,7 @@ namespace Catch {
|
|||||||
m_lastAssertionInfo = info;
|
m_lastAssertionInfo = info;
|
||||||
AssertionResultData data( resultType, LazyExpression( negated ) );
|
AssertionResultData data( resultType, LazyExpression( negated ) );
|
||||||
|
|
||||||
AssertionResult assertionResult{ info, data };
|
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
|
||||||
assertionResult.m_resultData.lazyExpression.m_transientExpression = expr;
|
assertionResult.m_resultData.lazyExpression.m_transientExpression = expr;
|
||||||
|
|
||||||
assertionEnded( assertionResult );
|
assertionEnded( assertionResult );
|
||||||
@ -597,7 +597,8 @@ namespace Catch {
|
|||||||
|
|
||||||
AssertionResultData data( resultType, LazyExpression( false ) );
|
AssertionResultData data( resultType, LazyExpression( false ) );
|
||||||
data.message = static_cast<std::string>(message);
|
data.message = static_cast<std::string>(message);
|
||||||
AssertionResult assertionResult{ m_lastAssertionInfo, data };
|
AssertionResult assertionResult{ m_lastAssertionInfo,
|
||||||
|
CATCH_MOVE( data ) };
|
||||||
assertionEnded( assertionResult );
|
assertionEnded( assertionResult );
|
||||||
if ( !assertionResult.isOk() ) {
|
if ( !assertionResult.isOk() ) {
|
||||||
populateReaction( reaction );
|
populateReaction( reaction );
|
||||||
@ -623,7 +624,7 @@ namespace Catch {
|
|||||||
|
|
||||||
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
|
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
|
||||||
data.message = message;
|
data.message = message;
|
||||||
AssertionResult assertionResult{ info, data };
|
AssertionResult assertionResult{ info, CATCH_MOVE(data) };
|
||||||
assertionEnded( assertionResult );
|
assertionEnded( assertionResult );
|
||||||
populateReaction( reaction );
|
populateReaction( reaction );
|
||||||
}
|
}
|
||||||
@ -640,7 +641,7 @@ namespace Catch {
|
|||||||
|
|
||||||
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
|
AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );
|
||||||
data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
||||||
AssertionResult assertionResult{ info, data };
|
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
|
||||||
assertionEnded( assertionResult );
|
assertionEnded( assertionResult );
|
||||||
}
|
}
|
||||||
void RunContext::handleNonExpr(
|
void RunContext::handleNonExpr(
|
||||||
@ -651,7 +652,7 @@ namespace Catch {
|
|||||||
m_lastAssertionInfo = info;
|
m_lastAssertionInfo = info;
|
||||||
|
|
||||||
AssertionResultData data( resultType, LazyExpression( false ) );
|
AssertionResultData data( resultType, LazyExpression( false ) );
|
||||||
AssertionResult assertionResult{ info, data };
|
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
|
||||||
assertionEnded( assertionResult );
|
assertionEnded( assertionResult );
|
||||||
|
|
||||||
if( !assertionResult.isOk() )
|
if( !assertionResult.isOk() )
|
||||||
|
Loading…
Reference in New Issue
Block a user