Skip to content

Commit 10f6248

Browse files
committed
AssertionHandler uses RunContext directly to avoid virtual dispatch
1 parent be2dfb4 commit 10f6248

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/catch2/internal/catch_assertion_handler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
1212
#include <catch2/internal/catch_context.hpp>
1313
#include <catch2/internal/catch_debugger.hpp>
14+
#include <catch2/internal/catch_run_context.hpp>
1415
#include <catch2/internal/catch_test_failure_exception.hpp>
1516
#include <catch2/matchers/catch_matchers_string.hpp>
1617

@@ -26,7 +27,7 @@ namespace Catch {
2627
StringRef capturedExpression,
2728
ResultDisposition::Flags resultDisposition )
2829
: m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },
29-
m_resultCapture( getResultCapture() )
30+
m_resultCapture( static_cast<RunContext&>(getResultCapture()) )
3031
{
3132
m_resultCapture.notifyAssertionStarted( m_assertionInfo );
3233
}

src/catch2/internal/catch_assertion_handler.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Catch {
1717

18-
class IResultCapture;
18+
class RunContext;
1919

2020
struct AssertionReaction {
2121
bool shouldDebugBreak = false;
@@ -27,7 +27,10 @@ namespace Catch {
2727
AssertionInfo m_assertionInfo;
2828
AssertionReaction m_reaction;
2929
bool m_completed = false;
30-
IResultCapture& m_resultCapture;
30+
// Since all uses are hidden in the .cpp file, we can directly use
31+
// the final type and avoid going through virtual dispatch, without
32+
// massive compilation time overhead.
33+
RunContext& m_resultCapture;
3134

3235
void finishIncomplete();
3336

0 commit comments

Comments
 (0)