bug #90981 (top-crash): sr=mscott, rs=waterson. the new |nsXPIDLC?String| implementation doesn't always have a buffer handle to give up. |BeginReading| won't do what you want in this case, so modify |do_AssignFromReadable| to elide copies from empty strings.

git-svn-id: svn://10.0.0.236/trunk@99334 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%mozilla.org
2001-07-16 20:29:30 +00:00
parent 987483a30e
commit 2ee4564df2
2 changed files with 36 additions and 24 deletions

View File

@@ -244,13 +244,16 @@ void
nsAString::do_AssignFromReadable( const self_type& aReadable )
{
SetLength(0);
SetLength(aReadable.Length());
// first setting the length to |0| avoids copying characters only to be overwritten later
// in the case where the implementation decides to re-allocate
if ( !aReadable.IsEmpty() )
{
SetLength(aReadable.Length());
// first setting the length to |0| avoids copying characters only to be overwritten later
// in the case where the implementation decides to re-allocate
const_iterator fromBegin, fromEnd;
iterator toBegin;
copy_string(aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), BeginWriting(toBegin));
const_iterator fromBegin, fromEnd;
iterator toBegin;
copy_string(aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), BeginWriting(toBegin));
}
}
void
@@ -704,13 +707,16 @@ void
nsACString::do_AssignFromReadable( const self_type& aReadable )
{
SetLength(0);
SetLength(aReadable.Length());
// first setting the length to |0| avoids copying characters only to be overwritten later
// in the case where the implementation decides to re-allocate
if ( !aReadable.IsEmpty() )
{
SetLength(aReadable.Length());
// first setting the length to |0| avoids copying characters only to be overwritten later
// in the case where the implementation decides to re-allocate
const_iterator fromBegin, fromEnd;
iterator toBegin;
copy_string(aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), BeginWriting(toBegin));
const_iterator fromBegin, fromEnd;
iterator toBegin;
copy_string(aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), BeginWriting(toBegin));
}
}
void