Avoid allocations when looking for trackers

Now we delay allocating owning `NameAndLocation` instances until
we construct a new tracker (because a tracker's lifetime can be
significantly different from the underlying tracked-thing's name).

This saves 4239 allocations (436948 -> 432709) when running
`./tests/SelfTest -o /dev/null`, at some cost to code clarity
due to introducing a new ref type, `NameAndLocationRef`.
This commit is contained in:
Martin Hořeňovský
2023-01-27 22:12:57 +01:00
parent 906552f8c8
commit 43f02027e4
4 changed files with 71 additions and 39 deletions

View File

@@ -14,8 +14,8 @@
using namespace Catch;
namespace {
Catch::TestCaseTracking::NameAndLocation makeNAL( std::string const& name ) {
return Catch::TestCaseTracking::NameAndLocation( name, Catch::SourceLineInfo("",0) );
Catch::TestCaseTracking::NameAndLocationRef makeNAL( StringRef name ) {
return Catch::TestCaseTracking::NameAndLocationRef( name, Catch::SourceLineInfo("",0) );
}
}