Clear unscoped messages lazily

This improves the fast path performance for successful assertions
by about 7%, at the cost of potentially keeping around the message
allocation longer.
This commit is contained in:
Martin Hořeňovský
2025-07-21 21:50:51 +02:00
parent 9c5c21df82
commit 5aa8d11321
2 changed files with 11 additions and 3 deletions
+6 -2
View File
@@ -296,6 +296,10 @@ namespace Catch {
}
{
if ( m_clearMessageScopes ) {
m_messageScopes.clear();
m_clearMessageScopes = false;
}
auto _ = scopedDeactivate( *m_outputRedirect );
m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) );
}
@@ -524,9 +528,9 @@ namespace Catch {
void RunContext::assertionPassedFastPath(SourceLineInfo lineInfo) {
m_lastKnownLineInfo = lineInfo;
m_lastAssertionPassed = true;
++m_totals.assertions.passed;
m_messageScopes.clear();
m_lastAssertionPassed = true;
m_clearMessageScopes = true;
}
bool RunContext::aborting() const {