зеркало из https://github.com/mozilla/gecko-dev.git
Bug 711491. Switch profile export to StringBuilder.
This should help performance some. --HG-- extra : rebase_source : 53aa5b61e95745475283940dd8cd053c84d2bd74
This commit is contained in:
Родитель
8e52a1df42
Коммит
8435995c3d
|
@ -44,8 +44,10 @@
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "prenv.h"
|
#include "prenv.h"
|
||||||
#include "shared-libraries.h"
|
#include "shared-libraries.h"
|
||||||
|
#include "mozilla/StringBuilder.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -158,7 +160,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToString(string* profile)
|
void ToString(StringBuilder &profile)
|
||||||
{
|
{
|
||||||
if (mNeedsSharedLibraryInfo) {
|
if (mNeedsSharedLibraryInfo) {
|
||||||
// Can't be called from signal because
|
// Can't be called from signal because
|
||||||
|
@ -166,10 +168,9 @@ public:
|
||||||
mSharedLibraryInfo = SharedLibraryInfo::GetInfoForSelf();
|
mSharedLibraryInfo = SharedLibraryInfo::GetInfoForSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
*profile = "";
|
|
||||||
int oldReadPos = mReadPos;
|
int oldReadPos = mReadPos;
|
||||||
while (mReadPos != mWritePos) {
|
while (mReadPos != mWritePos) {
|
||||||
*profile += mEntries[mReadPos].TagToString(this);
|
profile.Append(mEntries[mReadPos].TagToString(this).c_str());
|
||||||
mReadPos = (mReadPos + 1) % mEntrySize;
|
mReadPos = (mReadPos + 1) % mEntrySize;
|
||||||
}
|
}
|
||||||
mReadPos = oldReadPos;
|
mReadPos = oldReadPos;
|
||||||
|
@ -456,11 +457,11 @@ char* mozilla_sampler_get_profile() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
string profile;
|
StringBuilder profile;
|
||||||
t->GetProfile()->ToString(&profile);
|
t->GetProfile()->ToString(profile);
|
||||||
|
|
||||||
char *rtn = (char*)malloc( (strlen(profile.c_str())+1) * sizeof(char) );
|
char *rtn = (char*)malloc( (profile.Length()+1) * sizeof(char) );
|
||||||
strcpy(rtn, profile.c_str());
|
strcpy(rtn, profile.Buffer());
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче