Avoid copying NameAndLocationRef when passed as argument

`NameAndLocationRef` is pretty large type, so even in release build,
it is unlikely to be passed in registers. In addition to the fact
that some platforms currently do not allow passing even small types
in register (Windows ABI!!), it is better to pass it as a ref,
effectively passing around a pointer.
This commit is contained in:
Martin Hořeňovský 2023-02-19 23:53:34 +01:00
parent e1dbad4c9e
commit 4f7c8cb28a
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 7 additions and 7 deletions

View File

@ -34,7 +34,7 @@ namespace Catch {
{}
~GeneratorTracker() override;
static GeneratorTracker* acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocationRef nameAndLocation ) {
static GeneratorTracker* acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocationRef const& nameAndLocation ) {
GeneratorTracker* tracker;
ITracker& currentTracker = ctx.currentTracker();

View File

@ -38,7 +38,7 @@ namespace TestCaseTracking {
m_children.push_back( CATCH_MOVE(child) );
}
ITracker* ITracker::findChild( NameAndLocationRef nameAndLocation ) {
ITracker* ITracker::findChild( NameAndLocationRef const& nameAndLocation ) {
auto it = std::find_if(
m_children.begin(),
m_children.end(),
@ -177,7 +177,7 @@ namespace TestCaseTracking {
bool SectionTracker::isSectionTracker() const { return true; }
SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocationRef nameAndLocation ) {
SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocationRef const& nameAndLocation ) {
SectionTracker* tracker;
ITracker& currentTracker = ctx.currentTracker();

View File

@ -49,11 +49,11 @@ namespace TestCaseTracking {
name( name_ ), location( location_ ) {}
friend bool operator==( NameAndLocation const& lhs,
NameAndLocationRef rhs ) {
NameAndLocationRef const& rhs ) {
return StringRef( lhs.name ) == rhs.name &&
lhs.location == rhs.location;
}
friend bool operator==( NameAndLocationRef lhs,
friend bool operator==( NameAndLocationRef const& lhs,
NameAndLocation const& rhs ) {
return rhs == lhs;
}
@ -125,7 +125,7 @@ namespace TestCaseTracking {
*
* Returns nullptr if not found.
*/
ITracker* findChild( NameAndLocationRef nameAndLocation );
ITracker* findChild( NameAndLocationRef const& nameAndLocation );
//! Have any children been added?
bool hasChildren() const {
return !m_children.empty();
@ -212,7 +212,7 @@ namespace TestCaseTracking {
bool isComplete() const override;
static SectionTracker& acquire( TrackerContext& ctx, NameAndLocationRef nameAndLocation );
static SectionTracker& acquire( TrackerContext& ctx, NameAndLocationRef const& nameAndLocation );
void tryOpen();