mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Cache IResultCapture in AssertionHandler to avoid repeated lookups
This commit is contained in:
		| @@ -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(); | ||||
|   | ||||
| @@ -15,6 +15,7 @@ namespace Catch { | ||||
|  | ||||
|     struct TestFailureException{}; | ||||
|     struct AssertionResultData; | ||||
|     struct IResultCapture; | ||||
|  | ||||
|     class LazyExpression { | ||||
|         friend class AssertionHandler; | ||||
| @@ -37,6 +38,7 @@ namespace Catch { | ||||
|         bool m_shouldDebugBreak = false; | ||||
|         bool m_shouldThrow = false; | ||||
|         bool m_completed = false; | ||||
|         IResultCapture& m_resultCapture; | ||||
|  | ||||
|     public: | ||||
|         AssertionHandler | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash