mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 826521 (part 1) - Add SizeOfIncludingThisEvenIfShared() for strings. r=bz.
--HG-- extra : rebase_source : 5c10fc346ba0c5fa76d947a97254e9ebc49353e1
This commit is contained in:
parent
ec85f11f45
commit
f7ae295c20
@ -148,6 +148,17 @@ class nsStringBuffer
|
||||
* This measures the size only if the StringBuffer is unshared.
|
||||
*/
|
||||
size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||
|
||||
/**
|
||||
* This measures the size regardless of whether the StringBuffer is
|
||||
* unshared.
|
||||
*
|
||||
* WARNING: Only use this if you really know what you are doing, because
|
||||
* it can easily lead to double-counting strings. If you do use them,
|
||||
* please explain clearly in a comment why it's safe and won't lead to
|
||||
* double-counting.
|
||||
*/
|
||||
size_t SizeOfIncludingThisEvenIfShared(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||
};
|
||||
|
||||
#endif /* !defined(nsStringBuffer_h__ */
|
||||
|
@ -630,6 +630,17 @@ class nsTSubstring_CharT
|
||||
size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
const;
|
||||
|
||||
/**
|
||||
* WARNING: Only use these functions if you really know what you are
|
||||
* doing, because they can easily lead to double-counting strings. If
|
||||
* you do use them, please explain clearly in a comment why it's safe
|
||||
* and won't lead to double-counting.
|
||||
*/
|
||||
size_t SizeOfExcludingThisEvenIfShared(nsMallocSizeOfFun mallocSizeOf)
|
||||
const;
|
||||
size_t SizeOfIncludingThisEvenIfShared(nsMallocSizeOfFun mallocSizeOf)
|
||||
const;
|
||||
|
||||
protected:
|
||||
|
||||
friend class nsTObsoleteAStringThunk_CharT;
|
||||
|
@ -293,6 +293,12 @@ nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) c
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsStringBuffer::SizeOfIncludingThisEvenIfShared(nsMallocSizeOfFun aMallocSizeOf) const
|
||||
{
|
||||
return aMallocSizeOf(this);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -888,7 +888,7 @@ nsTSubstring_CharT::SizeOfExcludingThisMustBeUnshared(
|
||||
if (mFlags & F_SHARED) {
|
||||
return nsStringBuffer::FromData(mData)->
|
||||
SizeOfIncludingThisMustBeUnshared(mallocSizeOf);
|
||||
}
|
||||
}
|
||||
if (mFlags & F_OWNED) {
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
@ -920,6 +920,22 @@ nsTSubstring_CharT::SizeOfExcludingThisIfUnshared(
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfExcludingThisEvenIfShared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
// This is identical to SizeOfExcludingThisMustBeUnshared except for the
|
||||
// F_SHARED case.
|
||||
if (mFlags & F_SHARED) {
|
||||
return nsStringBuffer::FromData(mData)->
|
||||
SizeOfIncludingThisEvenIfShared(mallocSizeOf);
|
||||
}
|
||||
if (mFlags & F_OWNED) {
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfIncludingThisMustBeUnshared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
@ -934,3 +950,10 @@ nsTSubstring_CharT::SizeOfIncludingThisIfUnshared(
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisIfUnshared(mallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsTSubstring_CharT::SizeOfIncludingThisEvenIfShared(
|
||||
nsMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisEvenIfShared(mallocSizeOf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user