From 10f62484bff73e3a58a411e2e10b4e1c13cfba9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 13 Apr 2026 22:56:55 +0200 Subject: [PATCH] AssertionHandler uses RunContext directly to avoid virtual dispatch --- src/catch2/internal/catch_assertion_handler.cpp | 3 ++- src/catch2/internal/catch_assertion_handler.hpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp index 5a4806e9..79d5dcd8 100644 --- a/src/catch2/internal/catch_assertion_handler.cpp +++ b/src/catch2/internal/catch_assertion_handler.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -26,7 +27,7 @@ namespace Catch { StringRef capturedExpression, ResultDisposition::Flags resultDisposition ) : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, - m_resultCapture( getResultCapture() ) + m_resultCapture( static_cast(getResultCapture()) ) { m_resultCapture.notifyAssertionStarted( m_assertionInfo ); } diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index bc37469d..93a70b1a 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -15,7 +15,7 @@ namespace Catch { - class IResultCapture; + class RunContext; struct AssertionReaction { bool shouldDebugBreak = false; @@ -27,7 +27,10 @@ namespace Catch { AssertionInfo m_assertionInfo; AssertionReaction m_reaction; bool m_completed = false; - IResultCapture& m_resultCapture; + // Since all uses are hidden in the .cpp file, we can directly use + // the final type and avoid going through virtual dispatch, without + // massive compilation time overhead. + RunContext& m_resultCapture; void finishIncomplete();