diff options
| author | Martin Hořeňovský | 2026-08-22 23:28:11 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-08-22 23:28:11 +0200 |
| commit | ef3a728265292e6a1dbec727b0099d3d8b3f6420 (patch) | |
| tree | 7c2ddb997a6a1fdbd1ad25edc18966ee63ebd4dd /src/catch2/internal/catch_test_case_registry_impl.cpp | |
| parent | 69da66ee7370d7c249ba6f2a322a78dcdd623761 (diff) | |
| download | catch3-ef3a728265292e6a1dbec727b0099d3d8b3f6420.tar.gz | |
Don't store extra copy of all `TestCaseInfo*` in `TestRegistry`
We used to store a full vector of "views" of the registered test infos,
so that it can be retrieved externally. However, the only user of that
interface left was `Session`, specifically `Session::applyFilenameAsTags`.
By moving the adding of the filename tags into the `ITestCaseRegistry`
interface, we avoid storing the vector and make the initial test registration
faster.
The new code is ugly and shows a design/layering issue, but no worse than
the previous approach did.
Diffstat (limited to 'src/catch2/internal/catch_test_case_registry_impl.cpp')
| -rw-r--r-- | src/catch2/internal/catch_test_case_registry_impl.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/catch2/internal/catch_test_case_registry_impl.cpp b/src/catch2/internal/catch_test_case_registry_impl.cpp index d23056bc..e0d7c139 100644 --- a/src/catch2/internal/catch_test_case_registry_impl.cpp +++ b/src/catch2/internal/catch_test_case_registry_impl.cpp @@ -131,21 +131,21 @@ namespace Catch { // We pre-reserve some reasonable number of tests to avoid the // initial geometric growth churning during test registration. m_handles.reserve( kInitialTestCount ); - m_viewed_test_infos.reserve( kInitialTestCount ); - m_owned_test_infos.reserve( kInitialTestCount ); + m_test_infos.reserve( kInitialTestCount ); m_invokers.reserve( kInitialTestCount ); } TestRegistry::~TestRegistry() = default; void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) { m_handles.emplace_back(testInfo.get(), testInvoker.get()); - m_viewed_test_infos.push_back(testInfo.get()); - m_owned_test_infos.push_back(CATCH_MOVE(testInfo)); + m_test_infos.push_back(CATCH_MOVE(testInfo)); m_invokers.push_back(CATCH_MOVE(testInvoker)); } - std::vector<TestCaseInfo*> const& TestRegistry::getAllInfos() const { - return m_viewed_test_infos; + void TestRegistry::enableFilenameTags() { + for (auto& info : m_test_infos) { + info->addFilenameTag(); + } } std::vector<TestCaseHandle> const& TestRegistry::getAllTests() const { |