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.
This commit is contained in:
parent
41bbaa6d57
commit
1d1ccf8f3c
38 changed files with 141 additions and 125 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue