diff options
| author | Martin Hořeňovský | 2025-07-21 19:45:43 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2025-07-21 21:50:51 +0200 |
| commit | 5aa8d113215bd9a97ecc1a2f3fc9506947a2fa57 (patch) | |
| tree | bec8098a6e8809026ead0eaabb9ca00762f4d040 /src/catch2/internal/catch_run_context.cpp | |
| parent | 9c5c21df82372b9d266f6b6bc1cf0edd71337109 (diff) | |
| download | catch3-5aa8d113215bd9a97ecc1a2f3fc9506947a2fa57.tar.gz | |
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.
Diffstat (limited to 'src/catch2/internal/catch_run_context.cpp')
| -rw-r--r-- | src/catch2/internal/catch_run_context.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 118d37f8..dca16618 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -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 { |