fixes bug 311456 "Calling Truncate() on an nsAutoString makes next append work hard and doesn't clear F_VOIDED flag" r=bzbarsky

git-svn-id: svn://10.0.0.236/trunk@188910 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2006-02-04 00:42:18 +00:00
parent 9d492034c5
commit 47f1c672ec
2 changed files with 73 additions and 1 deletions

View File

@@ -79,8 +79,10 @@ nsTSubstring_CharT::MutatePrep( size_type capacity, char_type** oldData, PRUint3
if (curCapacity != size_type(-1))
{
if (capacity <= curCapacity)
if (capacity <= curCapacity) {
mFlags &= ~F_VOIDED; // mutation clears voided flag
return PR_TRUE;
}
if (curCapacity > 0)
{
@@ -119,6 +121,7 @@ nsTSubstring_CharT::MutatePrep( size_type capacity, char_type** oldData, PRUint3
hdr = newHdr;
mData = (char_type*) hdr->Data();
mFlags &= ~F_VOIDED; // mutation clears voided flag
return PR_TRUE;
}
}
@@ -562,6 +565,11 @@ nsTSubstring_CharT::SetCapacity( size_type capacity )
void
nsTSubstring_CharT::SetLength( size_type length )
{
if (mLength == length) {
mFlags &= ~F_VOIDED; // mutation clears voided flag
return;
}
SetCapacity(length);
// XXX(darin): SetCapacity may fail, but it doesn't give us a way to find