mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 600301 - Optimize ReplacePrep, r=benjamin, a=benjamin
--HG-- extra : rebase_source : 92cff8659239f2e62a9588234f9d3ef00f255c85
This commit is contained in:
parent
1adf5c8c45
commit
e257d02ebd
@ -659,8 +659,25 @@ class nsTSubstring_CharT
|
|||||||
* this function returns false if is unable to allocate sufficient
|
* this function returns false if is unable to allocate sufficient
|
||||||
* memory.
|
* memory.
|
||||||
*/
|
*/
|
||||||
PRBool NS_FASTCALL ReplacePrep( index_type cutStart, size_type cutLength, size_type newLength );
|
PRBool ReplacePrep(index_type cutStart, size_type cutLength,
|
||||||
|
size_type newLength)
|
||||||
|
{
|
||||||
|
cutLength = NS_MIN(cutLength, mLength - cutStart);
|
||||||
|
PRUint32 newTotalLen = mLength - cutLength + newLength;
|
||||||
|
if (cutStart == mLength && Capacity() > newTotalLen) {
|
||||||
|
mFlags &= ~F_VOIDED;
|
||||||
|
mData[newTotalLen] = char_type(0);
|
||||||
|
mLength = newTotalLen;
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
return ReplacePrepInternal(cutStart, cutLength, newLength, newTotalLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRBool NS_FASTCALL ReplacePrepInternal(index_type cutStart,
|
||||||
|
size_type cutLength,
|
||||||
|
size_type newFragLength,
|
||||||
|
size_type newTotalLength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the number of writable storage units starting at mData.
|
* returns the number of writable storage units starting at mData.
|
||||||
* the value does not include space for the null-terminator character.
|
* the value does not include space for the null-terminator character.
|
||||||
|
@ -188,13 +188,9 @@ nsTSubstring_CharT::Finalize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsTSubstring_CharT::ReplacePrep( index_type cutStart, size_type cutLen, size_type fragLen )
|
nsTSubstring_CharT::ReplacePrepInternal(index_type cutStart, size_type cutLen,
|
||||||
|
size_type fragLen, size_type newLen)
|
||||||
{
|
{
|
||||||
// bound cut length
|
|
||||||
cutLen = NS_MIN(cutLen, mLength - cutStart);
|
|
||||||
|
|
||||||
PRUint32 newLen = mLength - cutLen + fragLen;
|
|
||||||
|
|
||||||
char_type* oldData;
|
char_type* oldData;
|
||||||
PRUint32 oldFlags;
|
PRUint32 oldFlags;
|
||||||
if (!MutatePrep(newLen, &oldData, &oldFlags))
|
if (!MutatePrep(newLen, &oldData, &oldFlags))
|
||||||
|
Loading…
Reference in New Issue
Block a user