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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/interfaces
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-05-25 09:45:24 +0200
committerMartin Hořeňovský2020-05-31 15:20:24 +0200
commit1d1ccf8f3c0c9e121b16afd4fafb850d14ef9fb0 (patch)
tree0a292cf929c75743993d42453312e08888ef7c0a /src/catch2/interfaces
parent41bbaa6d573a598fe0796fd0e391ed57eae62e30 (diff)
downloadcatch3-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/interfaces')
-rw-r--r--src/catch2/interfaces/catch_interfaces_exception.hpp3
-rw-r--r--src/catch2/interfaces/catch_interfaces_generatortracker.hpp4
-rw-r--r--src/catch2/interfaces/catch_interfaces_registry_hub.hpp6
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.hpp6
-rw-r--r--src/catch2/interfaces/catch_interfaces_testcase.hpp4
5 files changed, 12 insertions, 11 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_exception.hpp b/src/catch2/interfaces/catch_interfaces_exception.hpp
index e9fb9ef7..31b6dc20 100644
--- a/src/catch2/interfaces/catch_interfaces_exception.hpp
+++ b/src/catch2/interfaces/catch_interfaces_exception.hpp
@@ -10,6 +10,7 @@
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
+#include <catch2/internal/catch_unique_ptr.hpp>
#include <string>
#include <vector>
@@ -18,7 +19,7 @@ namespace Catch {
using exceptionTranslateFunction = std::string(*)();
struct IExceptionTranslator;
- using ExceptionTranslators = std::vector<std::unique_ptr<IExceptionTranslator const>>;
+ using ExceptionTranslators = std::vector<Detail::unique_ptr<IExceptionTranslator const>>;
struct IExceptionTranslator {
virtual ~IExceptionTranslator();
diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp
index fa08be0c..88615ef5 100644
--- a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp
+++ b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp
@@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_INTERFACES_GENERATORTRACKER_INCLUDED
#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORTRACKER_INCLUDED
-#include <memory>
+#include <catch2/internal/catch_unique_ptr.hpp>
namespace Catch {
@@ -29,7 +29,7 @@ namespace Catch {
// can be retrieved).
virtual bool next() = 0;
};
- using GeneratorBasePtr = std::unique_ptr<GeneratorUntypedBase>;
+ using GeneratorBasePtr = Catch::Detail::unique_ptr<GeneratorUntypedBase>;
} // namespace Generators
diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
index e292763d..3e99d215 100644
--- a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
+++ b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
@@ -9,9 +9,9 @@
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
#include <catch2/internal/catch_common.hpp>
+#include <catch2/internal/catch_unique_ptr.hpp>
#include <string>
-#include <memory>
namespace Catch {
@@ -28,7 +28,7 @@ namespace Catch {
class StartupExceptionRegistry;
- using IReporterFactoryPtr = std::unique_ptr<IReporterFactory>;
+ using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
struct IRegistryHub {
virtual ~IRegistryHub();
@@ -46,7 +46,7 @@ namespace Catch {
virtual ~IMutableRegistryHub();
virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
virtual void registerListener( IReporterFactoryPtr factory ) = 0;
- virtual void registerTest(std::unique_ptr<TestCaseInfo>&& testInfo, std::unique_ptr<ITestInvoker>&& invoker) = 0;
+ virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0;
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
virtual void registerStartupException() noexcept = 0;
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp
index 408db425..5f0bcfc6 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp
@@ -17,6 +17,7 @@
#include <catch2/internal/catch_message_info.hpp>
#include <catch2/internal/catch_option.hpp>
#include <catch2/internal/catch_stringref.hpp>
+#include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/benchmark/catch_estimate.hpp>
#include <catch2/benchmark/catch_outlier_classification.hpp>
@@ -25,7 +26,6 @@
#include <string>
#include <iosfwd>
#include <map>
-#include <memory>
#include <algorithm>
namespace Catch {
@@ -222,14 +222,14 @@ namespace Catch {
virtual void listTags(std::vector<TagInfo> const& tags, Config const& config);
};
- using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;
+ using IStreamingReporterPtr = Detail::unique_ptr<IStreamingReporter>;
struct IReporterFactory {
virtual ~IReporterFactory();
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0;
virtual std::string getDescription() const = 0;
};
- using IReporterFactoryPtr = std::unique_ptr<IReporterFactory>;
+ using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
struct IReporterRegistry {
using FactoryMap = std::map<std::string, IReporterFactoryPtr>;
diff --git a/src/catch2/interfaces/catch_interfaces_testcase.hpp b/src/catch2/interfaces/catch_interfaces_testcase.hpp
index d176b490..aecc0871 100644
--- a/src/catch2/interfaces/catch_interfaces_testcase.hpp
+++ b/src/catch2/interfaces/catch_interfaces_testcase.hpp
@@ -9,7 +9,6 @@
#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
#include <vector>
-#include <memory>
namespace Catch {
@@ -26,7 +25,8 @@ namespace Catch {
struct ITestCaseRegistry {
virtual ~ITestCaseRegistry();
- virtual std::vector<std::unique_ptr<TestCaseInfo>> const& getAllInfos() const = 0;
+ // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later
+ virtual std::vector<TestCaseInfo* > const& getAllInfos() const = 0;
virtual std::vector<TestCaseHandle> const& getAllTests() const = 0;
virtual std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const = 0;
};