зеркало из https://github.com/mozilla/pjs.git
Bug 682431 (part 1) - Fix up ns{String,CString} SizeOf* functions. r=bz.
--HG-- extra : rebase_source : 85813ee7d843b6422f1a80a36a06fb42aa93b801
This commit is contained in:
Родитель
ad43db3cf0
Коммит
c3238e62b6
|
@ -595,27 +595,14 @@ class nsTSubstring_CharT
|
|||
#endif /* DEBUG || FORCE_BUILD_REFCNT_LOGGING */
|
||||
|
||||
size_t SizeOfExcludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
NS_ASSERTION(!(mFlags & F_SHARED), "string is shared");
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
|
||||
const;
|
||||
size_t SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisMustBeUnshared(mallocSizeOf);
|
||||
}
|
||||
const;
|
||||
|
||||
size_t SizeOfExcludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
if (mFlags & F_SHARED)
|
||||
return 0;
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
|
||||
const;
|
||||
size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisIfUnshared(mallocSizeOf);
|
||||
}
|
||||
const;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -863,3 +863,56 @@ nsTSubstring_CharT::DoAppendFloat( double aFloat, int digits )
|
|||
AppendASCII(buf);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfExcludingThisMustBeUnshared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
if (mFlags & F_SHARED) {
|
||||
return nsStringBuffer::FromData(mData)->
|
||||
SizeOfIncludingThisMustBeUnshared(mallocSizeOf);
|
||||
}
|
||||
if (mFlags & F_OWNED) {
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
|
||||
// If we reach here, exactly one of the following must be true:
|
||||
// - F_VOIDED is set, and mData points to sEmptyBuffer;
|
||||
// - F_FIXED is set, and mData points to a buffer within a string
|
||||
// object (e.g. nsAutoString);
|
||||
// - None of F_SHARED, F_OWNED, F_FIXED is set, and mData points to a buffer
|
||||
// owned by something else.
|
||||
//
|
||||
// In all three cases, we don't measure it.
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfExcludingThisIfUnshared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
// This is identical to SizeOfExcludingThisMustBeUnshared except for the
|
||||
// F_SHARED case.
|
||||
if (mFlags & F_SHARED) {
|
||||
return nsStringBuffer::FromData(mData)->
|
||||
SizeOfIncludingThisIfUnshared(mallocSizeOf);
|
||||
}
|
||||
if (mFlags & F_OWNED) {
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfIncludingThisMustBeUnshared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisMustBeUnshared(mallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfIncludingThisIfUnshared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisIfUnshared(mallocSizeOf);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче