Bug 1229458 - Remove SizeOfIncludingThisMustBeUnshared() from string classes. r=mccr8.

The patch changes all uses of SizeOfIncludingThisMustBeUnshared() to
SizeOfIncludingThisIfUnshared(). This incurs the (tiny) cost of an unnecessary
IsReadonly() check for guaranteed-unshared strings, but avoids the possible
assertion failures that would occur when MustBeUnshared() was used incorrectly
on shared strings, which is an easy mistake to make.
This commit is contained in:
Nicholas Nethercote
2015-12-01 15:36:26 -08:00
parent d837453d60
commit 262f17feb6
10 changed files with 12 additions and 59 deletions

View File

@@ -316,21 +316,10 @@ nsStringBuffer::ToString(uint32_t aLen, nsACString& aStr,
accessor->set(data, aLen, flags);
}
size_t
nsStringBuffer::SizeOfIncludingThisMustBeUnshared(mozilla::MallocSizeOf aMallocSizeOf) const
{
MOZ_ASSERT(!IsReadonly(),
"shared StringBuffer in SizeOfIncludingThisMustBeUnshared");
return aMallocSizeOf(this);
}
size_t
nsStringBuffer::SizeOfIncludingThisIfUnshared(mozilla::MallocSizeOf aMallocSizeOf) const
{
if (!IsReadonly()) {
return SizeOfIncludingThisMustBeUnshared(aMallocSizeOf);
}
return 0;
return IsReadonly() ? 0 : aMallocSizeOf(this);
}
size_t