mirror of
https://github.com/catchorg/Catch2.git
synced 2025-11-02 04:59:32 +01:00
performance improvement - getCurrentContext
inlined getCurrentContext and getMutableContext Further work on #1086. Brings test from 0m37.913 to 0m25.584s Catch2 is now faster than Catch 1.x!!
This commit is contained in:
@@ -45,21 +45,16 @@ namespace Catch {
|
||||
IResultCapture* m_resultCapture = nullptr;
|
||||
};
|
||||
|
||||
namespace {
|
||||
Context* currentContext = nullptr;
|
||||
}
|
||||
IMutableContext& getCurrentMutableContext() {
|
||||
if( !currentContext )
|
||||
currentContext = new Context();
|
||||
return *currentContext;
|
||||
}
|
||||
IContext& getCurrentContext() {
|
||||
return getCurrentMutableContext();
|
||||
IMutableContext *IMutableContext::currentContext = nullptr;
|
||||
|
||||
void IMutableContext::createContext()
|
||||
{
|
||||
currentContext = new Context();
|
||||
}
|
||||
|
||||
void cleanUpContext() {
|
||||
delete currentContext;
|
||||
currentContext = nullptr;
|
||||
delete IMutableContext::currentContext;
|
||||
IMutableContext::currentContext = nullptr;
|
||||
}
|
||||
IContext::~IContext() = default;
|
||||
IMutableContext::~IMutableContext() = default;
|
||||
|
||||
Reference in New Issue
Block a user