Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

AssertionHandler uses RunContext directly to avoid virtual dispatch

Commit
10f62484bff73e3a58a411e2e10b4e1c13cfba9f
Author
Martin Hořeňovský ·
Parents
be2dfb45cc78

Files · Download .tar.gz

Changes

 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 <catch2/interfaces/catch_interfaces_registry_hub.hpp>
 #include <catch2/internal/catch_context.hpp>
 #include <catch2/internal/catch_debugger.hpp>
+#include <catch2/internal/catch_run_context.hpp>
 #include <catch2/internal/catch_test_failure_exception.hpp>
 #include <catch2/matchers/catch_matchers_string.hpp>
 
@@ -26,7 +27,7 @@ namespace Catch {
             StringRef capturedExpression,
             ResultDisposition::Flags resultDisposition )
     :   m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },
-        m_resultCapture( getResultCapture() )
+        m_resultCapture( static_cast<RunContext&>(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();