Bug 1167230 - Use nsCString instead of std::string in FrameKey in the profiler. (r=mstange)

This commit is contained in:
Shu-yu Guo 2015-05-26 22:58:40 -07:00
parent 95302871f0
commit 35c01fcb4f
2 changed files with 19 additions and 3 deletions

View File

@ -360,7 +360,10 @@ uint32_t UniqueStacks::Stack::GetOrAddIndex() const
uint32_t UniqueStacks::FrameKey::Hash() const
{
uint32_t hash = mozilla::HashString(mLocation.c_str(), mLocation.length());
uint32_t hash = 0;
if (!mLocation.IsEmpty()) {
hash = mozilla::HashString(mLocation.get());
}
if (mLine.isSome()) {
hash = mozilla::AddToHash(hash, *mLine);
}
@ -493,7 +496,7 @@ void UniqueStacks::StreamFrame(const OnStackFrameKey& aFrame)
mFrameTableWriter.StartArrayElement();
if (!aFrame.mJITFrameHandle) {
mUniqueStrings.WriteElement(mFrameTableWriter, aFrame.mLocation.c_str());
mUniqueStrings.WriteElement(mFrameTableWriter, aFrame.mLocation.get());
if (aFrame.mLine.isSome()) {
mFrameTableWriter.NullElement(); // implementation
mFrameTableWriter.NullElement(); // optimizations

View File

@ -109,7 +109,7 @@ class UniqueStacks
{
public:
struct FrameKey {
std::string mLocation;
nsCString mLocation;
mozilla::Maybe<unsigned> mLine;
mozilla::Maybe<unsigned> mCategory;
mozilla::Maybe<void*> mJITAddress;
@ -119,6 +119,14 @@ public:
: mLocation(aLocation)
{ }
FrameKey(const FrameKey& aToCopy)
: mLocation(aToCopy.mLocation)
, mLine(aToCopy.mLine)
, mCategory(aToCopy.mCategory)
, mJITAddress(aToCopy.mJITAddress)
, mJITDepth(aToCopy.mJITDepth)
{ }
FrameKey(void* aJITAddress, uint32_t aJITDepth)
: mJITAddress(mozilla::Some(aJITAddress))
, mJITDepth(mozilla::Some(aJITDepth))
@ -137,6 +145,11 @@ public:
, mJITFrameHandle(nullptr)
{ }
OnStackFrameKey(const OnStackFrameKey& aToCopy)
: FrameKey(aToCopy)
, mJITFrameHandle(aToCopy.mJITFrameHandle)
{ }
OnStackFrameKey(void* aJITAddress, unsigned aJITDepth)
: FrameKey(aJITAddress, aJITDepth)
, mJITFrameHandle(nullptr)