Bug 710054 - Add {nsString,nsCString}::SizeOf{In,Ex}cludingThis. r=bz.

--HG--
extra : rebase_source : 2f5eb0a61cc36bdefe420658a86e5badc79484df
This commit is contained in:
Nicholas Nethercote 2012-02-02 14:52:02 -08:00
Родитель 14d6cab89d
Коммит df90421a0d
1 изменённых файлов: 28 добавлений и 5 удалений

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

@ -585,15 +585,38 @@ class nsTSubstring_CharT
// XXXbz or can I just include nscore.h and use NS_BUILD_REFCNT_LOGGING?
#if defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING)
#define XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags );
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags );
#else
#undef XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags )
: mData(data),
mLength(length),
mFlags(flags) {}
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags )
: mData(data),
mLength(length),
mFlags(flags) {}
#endif /* DEBUG || FORCE_BUILD_REFCNT_LOGGING */
size_t SizeOfExcludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf)
{
NS_ASSERTION(!(mFlags & F_SHARED), "string is shared");
return mallocSizeOf(mData);
}
size_t SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf)
{
return mallocSizeOf(this) + SizeOfExcludingThisMustBeUnshared(mallocSizeOf);
}
size_t SizeOfExcludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
{
if (mFlags & F_SHARED)
return 0;
return mallocSizeOf(mData);
}
size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
{
return mallocSizeOf(this) + SizeOfExcludingThisIfUnshared(mallocSizeOf);
}
protected:
friend class nsTObsoleteAStringThunk_CharT;