mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 21:35:40 +02:00
Use the fast path for passing assertions in RunContext::handleNonExpr
`handleNonExpr` is responsible for handling assertions that do not result in a decomposable expression, e.g. `REQUIRE_THROWS`, or `REQUIRE_NOTHROW`. Running benchmark on these two macros specifically, with `REQUIRE_THROWS([](){ throw 1; }())`, and `REQUIRE_NOTHROW([](){}())`, we get these speedups: | | Debug | Release | |---------|--------|---------| | THROWS | 3.69x | 2.10x | | NOTHROW | 1.18x | 1.05x | Obviously the actual performance improvement is dependent on how expensive the expression under test is.
This commit is contained in:
@@ -720,6 +720,11 @@ namespace Catch {
|
||||
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
|
||||
|
||||
const auto isOk = assertionResult.isOk();
|
||||
if ( isOk && !m_includeSuccessfulResults ) {
|
||||
assertionPassedFastPath( info.lineInfo );
|
||||
return;
|
||||
}
|
||||
|
||||
assertionEnded( CATCH_MOVE(assertionResult) );
|
||||
if ( !isOk ) {
|
||||
populateReaction(
|
||||
|
Reference in New Issue
Block a user