Skip to content

Commit 715558f

Browse files
committed
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.
1 parent 55b14e1 commit 715558f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/catch2/internal/catch_run_context.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,11 @@ namespace Catch {
720720
AssertionResult assertionResult{ info, CATCH_MOVE( data ) };
721721

722722
const auto isOk = assertionResult.isOk();
723+
if ( isOk && !m_includeSuccessfulResults ) {
724+
assertionPassedFastPath( info.lineInfo );
725+
return;
726+
}
727+
723728
assertionEnded( CATCH_MOVE(assertionResult) );
724729
if ( !isOk ) {
725730
populateReaction(

0 commit comments

Comments
 (0)