Early evaluate line loc in NameAndLoc::operator==
I do not know if checking the tracker name or the tracker's file part of the location first would provide better results, but in the common case, the line part of the location check should be rather unique, because different `SECTION`s will have different source lines where they are defined. I also propagated this same check into `ITracker::findChild`, because this significantly improves performance of section tracking in Debug builds -> 10% in macro benchmark heavily focused on section tracking. In Release build there is usually no difference, because the inliner will inline `NameAndLoc::operator==` into `findChild`, and then eliminate the redundant check. (If the inliner decides against, then this still improves the performance on average).
This commit is contained in:
2 files changed
+17
-3
No files matched your search
@@ -43,7 +43,12 @@ namespace TestCaseTracking {
|
||||
m_children.begin(),
|
||||
m_children.end(),
|
||||
[&nameAndLocation]( ITrackerPtr const& tracker ) {
|
||||
return tracker->nameAndLocation() == nameAndLocation;
|
||||
auto const& tnameAndLoc = tracker->nameAndLocation();
|
||||
if ( tnameAndLoc.location.line !=
|
||||
nameAndLocation.location.line ) {
|
||||
return false;
|
||||
}
|
||||
return tnameAndLoc == nameAndLocation;
|
||||
} );
|
||||
return ( it != m_children.end() ) ? it->get() : nullptr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user