Don't use memcpy for single-character Replace/Assign since it performs worse than simple assignment. Bug 312681, r+sr=darin.
git-svn-id: svn://10.0.0.236/trunk@182378 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -283,6 +283,15 @@ nsTSubstring_CharT::EnsureMutable()
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// This version of Assign is optimized for single-character assignment.
|
||||
void
|
||||
nsTSubstring_CharT::Assign( char_type c )
|
||||
{
|
||||
if (ReplacePrep(0, mLength, 1))
|
||||
*mData = c;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsTSubstring_CharT::Assign( const char_type* data, size_type length )
|
||||
{
|
||||
@@ -421,6 +430,17 @@ nsTSubstring_CharT::Adopt( char_type* data, size_type length )
|
||||
}
|
||||
|
||||
|
||||
// This version of Replace is optimized for single-character replacement.
|
||||
void
|
||||
nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, char_type c )
|
||||
{
|
||||
cutStart = PR_MIN(cutStart, Length());
|
||||
|
||||
if (ReplacePrep(cutStart, cutLength, 1))
|
||||
mData[cutStart] = c;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user