mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Avoid allocating trimmed name for SectionTracker
This commit is contained in:
parent
0477326ad9
commit
fed1436246
@ -163,7 +163,7 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
SectionTracker::SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent )
|
SectionTracker::SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent )
|
||||||
: TrackerBase( CATCH_MOVE(nameAndLocation), ctx, parent ),
|
: TrackerBase( CATCH_MOVE(nameAndLocation), ctx, parent ),
|
||||||
m_trimmed_name(trim(ITracker::nameAndLocation().name))
|
m_trimmed_name(trim(StringRef(ITracker::nameAndLocation().name)))
|
||||||
{
|
{
|
||||||
if( parent ) {
|
if( parent ) {
|
||||||
while ( !parent->isSectionTracker() ) {
|
while ( !parent->isSectionTracker() ) {
|
||||||
|
@ -195,7 +195,11 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
class SectionTracker : public TrackerBase {
|
class SectionTracker : public TrackerBase {
|
||||||
std::vector<StringRef> m_filters;
|
std::vector<StringRef> m_filters;
|
||||||
std::string m_trimmed_name;
|
// Note that lifetime-wise we piggy back off the name stored in the `ITracker` parent`.
|
||||||
|
// Currently it allocates owns the name, so this is safe. If it is later refactored
|
||||||
|
// to not own the name, the name still has to outlive the `ITracker` parent, so
|
||||||
|
// this should still be safe.
|
||||||
|
StringRef m_trimmed_name;
|
||||||
public:
|
public:
|
||||||
SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent );
|
SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user