Reduce string copying and allocation in the parser by only copying the scanner buffer when we need to mutate the string. Allow a nsDependentString / nsDependentSubstring to be created without being bound to anything. Move StripChar() onto nsSubstring from nsString. Bug 269853, r=jst, sr=darin.
git-svn-id: svn://10.0.0.236/trunk@165773 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -299,30 +299,6 @@ nsTString_CharT::StripChars( const char* aSet )
|
||||
mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
|
||||
}
|
||||
|
||||
void
|
||||
nsTString_CharT::StripChar( char_type aChar, PRInt32 aOffset )
|
||||
{
|
||||
if (mLength == 0 || aOffset >= PRInt32(mLength))
|
||||
return;
|
||||
|
||||
EnsureMutable(); // XXX do this lazily?
|
||||
|
||||
// XXXdarin this code should defer writing until necessary.
|
||||
|
||||
char_type* to = mData + aOffset;
|
||||
char_type* from = mData + aOffset;
|
||||
char_type* end = mData + mLength;
|
||||
|
||||
while (from < end)
|
||||
{
|
||||
char_type theChar = *from++;
|
||||
if (aChar != theChar)
|
||||
*to++ = theChar;
|
||||
}
|
||||
*to = char_type(0); // add the null
|
||||
mLength = to - mData;
|
||||
}
|
||||
|
||||
void
|
||||
nsTString_CharT::StripWhitespace()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user