Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_assertionhandler.cpp
diff options
context:
space:
mode:
authorPhil Nash2017-11-23 19:21:09 +0000
committerPhil Nash2017-11-23 19:21:09 +0000
commitf417995afcac9c7a9af436bcb303f9fabb80d32b (patch)
tree5428d487083306a559adbd95322bcb47bae0b380 /include/internal/catch_assertionhandler.cpp
parent9329d97a43b36aa2499ac1bc1e7ed78815ca2584 (diff)
downloadcatch3-f417995afcac9c7a9af436bcb303f9fabb80d32b.tar.gz
Cache IResultCapture in AssertionHandler to avoid repeated lookups
Diffstat (limited to 'include/internal/catch_assertionhandler.cpp')
-rw-r--r--include/internal/catch_assertionhandler.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/include/internal/catch_assertionhandler.cpp b/include/internal/catch_assertionhandler.cpp
index 0fe8e3e9..34540e94 100644
--- a/include/internal/catch_assertionhandler.cpp
+++ b/include/internal/catch_assertionhandler.cpp
@@ -56,14 +56,15 @@ namespace Catch {
SourceLineInfo const& lineInfo,
StringRef capturedExpression,
ResultDisposition::Flags resultDisposition )
- : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }
+ : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },
+ m_resultCapture( getResultCapture() )
{
- getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo );
+ m_resultCapture.assertionStarting( m_assertionInfo );
}
AssertionHandler::~AssertionHandler() {
if ( !m_completed ) {
handle( ResultWas::ThrewException, "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE" );
- getCurrentContext().getResultCapture()->exceptionEarlyReported();
+ m_resultCapture.exceptionEarlyReported();
}
}
@@ -74,8 +75,8 @@ namespace Catch {
if(result && !getCurrentContext().getConfig()->includeSuccessfulResults())
{
- getCurrentContext().getResultCapture()->assertionRun();
- getCurrentContext().getResultCapture()->assertionPassed();
+ m_resultCapture.assertionRun();
+ m_resultCapture.assertionPassed();
return;
}
@@ -95,12 +96,12 @@ namespace Catch {
}
void AssertionHandler::handle( AssertionResultData const& resultData, ITransientExpression const* expr ) {
- getResultCapture().assertionRun();
+ m_resultCapture.assertionRun();
AssertionResult assertionResult{ m_assertionInfo, resultData };
assertionResult.m_resultData.lazyExpression.m_transientExpression = expr;
- getResultCapture().assertionEnded( assertionResult );
+ m_resultCapture.assertionEnded( assertionResult );
if( !assertionResult.isOk() ) {
m_shouldDebugBreak = getCurrentContext().getConfig()->shouldDebugBreak();