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:
@@ -39,6 +39,9 @@
|
||||
void
|
||||
nsTDependentSubstring_CharT::Rebind( const abstract_string_type& readable, PRUint32 startPos, PRUint32 length )
|
||||
{
|
||||
// If we currently own a buffer, release it.
|
||||
Finalize();
|
||||
|
||||
size_type strLength = readable.GetReadableBuffer((const char_type**) &mData);
|
||||
|
||||
if (startPos > strLength)
|
||||
@@ -53,6 +56,9 @@ nsTDependentSubstring_CharT::Rebind( const abstract_string_type& readable, PRUin
|
||||
void
|
||||
nsTDependentSubstring_CharT::Rebind( const substring_type& str, PRUint32 startPos, PRUint32 length )
|
||||
{
|
||||
// If we currently own a buffer, release it.
|
||||
Finalize();
|
||||
|
||||
size_type strLength = str.Length();
|
||||
|
||||
if (startPos > strLength)
|
||||
@@ -63,3 +69,16 @@ nsTDependentSubstring_CharT::Rebind( const substring_type& str, PRUint32 startPo
|
||||
|
||||
SetDataFlags(F_NONE);
|
||||
}
|
||||
|
||||
void
|
||||
nsTDependentSubstring_CharT::Rebind( const char_type* start, const char_type* end )
|
||||
{
|
||||
NS_ASSERTION(start && end, "nsTDependentSubstring must wrap a non-NULL buffer");
|
||||
|
||||
// If we currently own a buffer, release it.
|
||||
Finalize();
|
||||
|
||||
mData = NS_CONST_CAST(char_type*, start);
|
||||
mLength = end - start;
|
||||
SetDataFlags(F_NONE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user