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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user