diff --git a/tools/profiler/TableTicker.h b/tools/profiler/TableTicker.h index f67092a5f3e6..277354016549 100644 --- a/tools/profiler/TableTicker.h +++ b/tools/profiler/TableTicker.h @@ -9,6 +9,7 @@ #include "platform.h" #include "ProfileEntry.h" #include "mozilla/Mutex.h" +#include "mozilla/Vector.h" #include "IntelPowerGadget.h" #ifdef MOZ_TASK_TRACER #include "GeckoTaskTracer.h" @@ -23,15 +24,16 @@ hasFeature(const char** aFeatures, uint32_t aFeatureCount, const char* aFeature) return false; } +typedef mozilla::Vector ThreadNameFilterList; + static bool -threadSelected(ThreadInfo* aInfo, char** aThreadNameFilters, uint32_t aFeatureCount) { - if (aFeatureCount == 0) { +threadSelected(ThreadInfo* aInfo, const ThreadNameFilterList &aThreadNameFilters) { + if (aThreadNameFilters.empty()) { return true; } - for (uint32_t i = 0; i < aFeatureCount; ++i) { - const char* filterPrefix = aThreadNameFilters[i]; - if (strncmp(aInfo->Name(), filterPrefix, strlen(filterPrefix)) == 0) { + for (uint32_t i = 0; i < aThreadNameFilters.length(); ++i) { + if (aThreadNameFilters[i] == aInfo->Name()) { return true; } } @@ -55,7 +57,6 @@ class TableTicker: public Sampler { , mBuffer(new ProfileBuffer(aEntrySize)) , mSaveRequested(false) , mUnwinderThread(false) - , mFilterCount(aFilterCount) #if defined(XP_WIN) , mIntelPowerGadget(nullptr) #endif @@ -87,9 +88,9 @@ class TableTicker: public Sampler { #endif // Deep copy aThreadNameFilters - mThreadNameFilters = new char*[aFilterCount]; + MOZ_ALWAYS_TRUE(mThreadNameFilters.resize(aFilterCount)); for (uint32_t i = 0; i < aFilterCount; ++i) { - mThreadNameFilters[i] = strdup(aThreadNameFilters[i]); + mThreadNameFilters[i] = aThreadNameFilters[i]; } sStartTime = mozilla::TimeStamp::Now(); @@ -150,7 +151,7 @@ class TableTicker: public Sampler { return; } - if (!threadSelected(aInfo, mThreadNameFilters, mFilterCount)) { + if (!threadSelected(aInfo, mThreadNameFilters)) { return; } @@ -243,8 +244,7 @@ protected: // Keep the thread filter to check against new thread that // are started while profiling - char** mThreadNameFilters; - uint32_t mFilterCount; + ThreadNameFilterList mThreadNameFilters; bool mPrivacyMode; bool mAddMainThreadIO; bool mProfileMemory;