diff options
| author | Martin Hořeňovský | 2021-12-26 22:10:20 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-28 00:20:55 +0100 |
| commit | 45577a1f4c84eca059453908220cbdc7e1d34f93 (patch) | |
| tree | fd0978d2ef6cc5a975d66d852d59de6cb9ca1812 /src/catch2/internal | |
| parent | cbb6764fb1c22bbd283ea7af6a69d012c470ec58 (diff) | |
| download | catch3-45577a1f4c84eca059453908220cbdc7e1d34f93.tar.gz | |
Refactor implementation of case-insensitivity in tags
By not materializing the lower cased tags ahead of time, we
save allocations at the cost of worsened performance when comparing
two tags.
Since there are rarely many tags, and commonly they are not
compared even if present, this is almost always a win. The new
implementation also improves the robustness of the code
responsible for handling tags in a case-insensitive manner.
Diffstat (limited to 'src/catch2/internal')
| -rw-r--r-- | src/catch2/internal/catch_list.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/catch2/internal/catch_list.cpp b/src/catch2/internal/catch_list.cpp index 20613c70..6d99dfb1 100644 --- a/src/catch2/internal/catch_list.cpp +++ b/src/catch2/internal/catch_list.cpp @@ -13,6 +13,7 @@ #include <catch2/interfaces/catch_interfaces_testcase.hpp> #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp> #include <catch2/internal/catch_move_and_forward.hpp> +#include <catch2/internal/catch_case_insensitive_comparisons.hpp> #include <catch2/internal/catch_context.hpp> #include <catch2/catch_config.hpp> @@ -32,12 +33,12 @@ namespace Catch { auto const& testSpec = config.testSpec(); std::vector<TestCaseHandle> matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config); - std::map<StringRef, TagInfo> tagCounts; + std::map<StringRef, TagInfo, Detail::CaseInsensitiveLess> tagCounts; for (auto const& testCase : matchedTestCases) { for (auto const& tagName : testCase.getTestCaseInfo().tags) { - auto it = tagCounts.find(tagName.lowerCased); + auto it = tagCounts.find(tagName.original); if (it == tagCounts.end()) - it = tagCounts.insert(std::make_pair(tagName.lowerCased, TagInfo())).first; + it = tagCounts.insert(std::make_pair(tagName.original, TagInfo())).first; it->second.add(tagName.original); } } |