Bug 1443587 - part 1 - make EventInfo string getters return dependent strings; r=chutten

These methods are returning nsCString wrappers for static char arrays;
we only need to return nsDependentCStrings, rather than allocating and
copying entirely new nsCString objects.
This commit is contained in:
Nathan Froyd 2018-03-07 11:00:44 -05:00
Родитель d7a8ae09e2
Коммит 472a014c69
2 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -32,9 +32,9 @@ struct CommonEventInfo {
mozilla::Telemetry::Common::RecordedProcessType record_in_processes;
// Convenience functions for accessing event strings.
const nsCString expiration_version() const;
const nsCString category() const;
const nsCString extra_key(uint32_t index) const;
const nsDependentCString expiration_version() const;
const nsDependentCString category() const;
const nsDependentCString extra_key(uint32_t index) const;
};
struct EventInfo {
@ -45,8 +45,8 @@ struct EventInfo {
uint32_t method_offset;
uint32_t object_offset;
const nsCString method() const;
const nsCString object() const;
const nsDependentCString method() const;
const nsDependentCString object() const;
};
} // namespace

Просмотреть файл

@ -199,37 +199,37 @@ private:
};
// Implements the methods for EventInfo.
const nsCString
const nsDependentCString
EventInfo::method() const
{
return nsCString(&gEventsStringTable[this->method_offset]);
return nsDependentCString(&gEventsStringTable[this->method_offset]);
}
const nsCString
const nsDependentCString
EventInfo::object() const
{
return nsCString(&gEventsStringTable[this->object_offset]);
return nsDependentCString(&gEventsStringTable[this->object_offset]);
}
// Implements the methods for CommonEventInfo.
const nsCString
const nsDependentCString
CommonEventInfo::category() const
{
return nsCString(&gEventsStringTable[this->category_offset]);
return nsDependentCString(&gEventsStringTable[this->category_offset]);
}
const nsCString
const nsDependentCString
CommonEventInfo::expiration_version() const
{
return nsCString(&gEventsStringTable[this->expiration_version_offset]);
return nsDependentCString(&gEventsStringTable[this->expiration_version_offset]);
}
const nsCString
const nsDependentCString
CommonEventInfo::extra_key(uint32_t index) const
{
MOZ_ASSERT(index < this->extra_count);
uint32_t key_index = gExtraKeysTable[this->extra_index + index];
return nsCString(&gEventsStringTable[key_index]);
return nsDependentCString(&gEventsStringTable[key_index]);
}
// Implementation for the EventRecord class.