diff --git a/mozilla/xpcom/string/public/nsTSubstring.h b/mozilla/xpcom/string/public/nsTSubstring.h index 2c19137490f..81158d034f6 100644 --- a/mozilla/xpcom/string/public/nsTSubstring.h +++ b/mozilla/xpcom/string/public/nsTSubstring.h @@ -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 ); diff --git a/mozilla/xpcom/string/src/nsTSubstring.cpp b/mozilla/xpcom/string/src/nsTSubstring.cpp index 1eb89b2de3b..f2872c2ff67 100644 --- a/mozilla/xpcom/string/src/nsTSubstring.cpp +++ b/mozilla/xpcom/string/src/nsTSubstring.cpp @@ -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 ) {