From f7b3cb515b49e9c9fc842bc064ad76a5946ad741 Mon Sep 17 00:00:00 2001 From: Neal Coombes Date: Mon, 20 Nov 2017 09:11:30 -0600 Subject: [PATCH] performance improvement - ~AssertionHandler, getConfig return value inlined ~AssertionHandler(), and changed getConfig to return shared_ptr const reference instead of by value (very expensive for shared_ptr's). Further work on #1086. Brings test from 0m20.635s to 0m17.186s --- include/internal/catch_assertionhandler.cpp | 8 -------- include/internal/catch_assertionhandler.h | 10 +++++++++- include/internal/catch_context.cpp | 2 +- include/internal/catch_context.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/internal/catch_assertionhandler.cpp b/include/internal/catch_assertionhandler.cpp index 3465269f..8bef64c1 100644 --- a/include/internal/catch_assertionhandler.cpp +++ b/include/internal/catch_assertionhandler.cpp @@ -8,10 +8,8 @@ #include "catch_assertionhandler.h" #include "catch_assertionresult.h" -#include "catch_interfaces_capture.h" #include "catch_interfaces_runner.h" #include "catch_interfaces_config.h" -#include "catch_context.h" #include "catch_debugger.h" #include "catch_interfaces_registry_hub.h" #include "catch_capture_matchers.h" @@ -60,12 +58,6 @@ namespace Catch { { getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo ); } - AssertionHandler::~AssertionHandler() { - if ( m_inExceptionGuard ) { - handle( ResultWas::ThrewException, "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE" ); - getCurrentContext().getResultCapture()->exceptionEarlyReported(); - } - } void AssertionHandler::handle( ITransientExpression const& expr ) { diff --git a/include/internal/catch_assertionhandler.h b/include/internal/catch_assertionhandler.h index 9fdbee4f..bfd6aeba 100644 --- a/include/internal/catch_assertionhandler.h +++ b/include/internal/catch_assertionhandler.h @@ -10,6 +10,8 @@ #include "catch_decomposer.h" #include "catch_assertioninfo.h" +#include "catch_context.h" +#include "catch_interfaces_capture.h" namespace Catch { @@ -44,7 +46,13 @@ namespace Catch { SourceLineInfo const& lineInfo, StringRef capturedExpression, ResultDisposition::Flags resultDisposition ); - ~AssertionHandler(); + ~AssertionHandler() + { + if ( m_inExceptionGuard ) { + handle( ResultWas::ThrewException, "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE" ); + getCurrentContext().getResultCapture()->exceptionEarlyReported(); + } + } void handle( ITransientExpression const& expr ); diff --git a/include/internal/catch_context.cpp b/include/internal/catch_context.cpp index 0341a6f1..3f1f196f 100644 --- a/include/internal/catch_context.cpp +++ b/include/internal/catch_context.cpp @@ -20,7 +20,7 @@ namespace Catch { return m_runner; } - virtual IConfigPtr getConfig() const override { + virtual IConfigPtr const & getConfig() const override { return m_config; } diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h index eb8611cc..5f9e2d8e 100644 --- a/include/internal/catch_context.h +++ b/include/internal/catch_context.h @@ -25,7 +25,7 @@ namespace Catch { virtual IResultCapture* getResultCapture() = 0; virtual IRunner* getRunner() = 0; - virtual IConfigPtr getConfig() const = 0; + virtual IConfigPtr const & getConfig() const = 0; }; struct IMutableContext : IContext