diff options
| author | Martin Hořeňovský | 2020-05-25 09:45:24 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-05-31 15:20:24 +0200 |
| commit | 1d1ccf8f3c0c9e121b16afd4fafb850d14ef9fb0 (patch) | |
| tree | 0a292cf929c75743993d42453312e08888ef7c0a /src/catch2/internal/catch_test_registry.cpp | |
| parent | 41bbaa6d573a598fe0796fd0e391ed57eae62e30 (diff) | |
| download | catch3-1d1ccf8f3c0c9e121b16afd4fafb850d14ef9fb0.tar.gz | |
Replace all uses of std::unique_ptr with Catch::Detail::unique_ptr
Doing some benchmarking with ClangBuildAnalyzer suggests that
compiling Catch2's `SelfTest` spends 10% of the time instantiating
`std::unique_ptr` for some interface types required for registering
and running tests.
The lesser compilation overhead of `Catch::Detail::unique_ptr` should
significantly reduce that time.
The compiled implementation was also changed to use the custom impl,
to avoid having to convert between using `std::unique_ptr` and
`Catch::Detail::unique_ptr`. This will likely also improve the compile
times of the implementation, but that is less important than improving
compilation times of the user's TUs with tests.
Diffstat (limited to 'src/catch2/internal/catch_test_registry.cpp')
| -rw-r--r-- | src/catch2/internal/catch_test_registry.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp index 070fde0d..583754e2 100644 --- a/src/catch2/internal/catch_test_registry.cpp +++ b/src/catch2/internal/catch_test_registry.cpp @@ -13,11 +13,11 @@ namespace Catch { - std::unique_ptr<ITestInvoker> makeTestInvoker( void(*testAsFunction)() ) { - return std::make_unique<TestInvokerAsFunction>( testAsFunction ); + Detail::unique_ptr<ITestInvoker> makeTestInvoker( void(*testAsFunction)() ) { + return Detail::unique_ptr<ITestInvoker>( new TestInvokerAsFunction( testAsFunction )); } - AutoReg::AutoReg( std::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept { + AutoReg::AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept { CATCH_TRY { getMutableRegistryHub() .registerTest( @@ -25,7 +25,8 @@ namespace Catch { extractClassName( classOrMethod ), nameAndTags, lineInfo), - std::move(invoker)); + std::move(invoker) + ); } CATCH_CATCH_ALL { // Do not throw when constructing global objects, instead register the exception to be processed later getMutableRegistryHub().registerStartupException(); |