mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Don't use memcpy for single-character Replace/Assign since it performs worse than simple assignment. Bug 312681, r+sr=darin.
This commit is contained in:
parent
7016d8085d
commit
ddd7501923
@ -300,7 +300,7 @@ class nsTSubstring_CharT : public nsTAString_CharT
|
||||
* assignment
|
||||
*/
|
||||
|
||||
void Assign( char_type c ) { Assign(&c, 1); }
|
||||
NS_COM void NS_FASTCALL Assign( char_type c );
|
||||
NS_COM void NS_FASTCALL Assign( const char_type* data, size_type length = size_type(-1) );
|
||||
NS_COM void NS_FASTCALL Assign( const self_type& );
|
||||
NS_COM void NS_FASTCALL Assign( const substring_tuple_type& );
|
||||
@ -341,7 +341,7 @@ class nsTSubstring_CharT : public nsTAString_CharT
|
||||
* buffer manipulation
|
||||
*/
|
||||
|
||||
void Replace( index_type cutStart, size_type cutLength, char_type c ) { Replace(cutStart, cutLength, &c, 1); }
|
||||
NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, char_type c );
|
||||
NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) );
|
||||
void Replace( index_type cutStart, size_type cutLength, const self_type& str ) { Replace(cutStart, cutLength, str.Data(), str.Length()); }
|
||||
NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const substring_tuple_type& tuple );
|
||||
|
@ -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 )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user