Bug 1511470 - part 1 - reduce copying of profile data in FinishGathering(); r=mstange

At this point, we've freshly allocated data for the generated JSON.
There's no need to copy it into a separate nsCString; we can simply
adopt the generated JSON into the nsCString, saving a copy.
This commit is contained in:
Nathan Froyd 2018-12-10 16:22:26 -05:00
parent dc6d556802
commit e1d14adf40

View File

@ -703,8 +703,10 @@ void nsProfiler::FinishGathering() {
mWriter->End();
UniquePtr<char[]> buf = mWriter->WriteFunc()->CopyData();
nsCString result(buf.get());
mPromiseHolder->Resolve(result, __func__);
size_t len = strlen(buf.get());
nsCString result;
result.Adopt(buf.release(), len);
mPromiseHolder->Resolve(std::move(result), __func__);
ResetGathering();
}