mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Add ReplaceChars with a char16_t array. Bug 979556, r=bsmedberg
This commit is contained in:
parent
108ae026f2
commit
a0be4ca960
@ -344,6 +344,9 @@ class nsTString_CharT : public nsTSubstring_CharT
|
||||
|
||||
void ReplaceChar( char_type aOldChar, char_type aNewChar );
|
||||
void ReplaceChar( const char* aSet, char_type aNewChar );
|
||||
#ifdef CharT_is_PRUnichar
|
||||
void ReplaceChar( const char16_t* aSet, char16_t aNewChar );
|
||||
#endif
|
||||
void ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue);
|
||||
void ReplaceSubstring( const char_type* aTarget, const char_type* aNewValue);
|
||||
|
||||
|
@ -915,6 +915,27 @@ nsString::FindCharInSet( const char16_t* aSet, int32_t aOffset ) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsString::ReplaceChar( const char16_t* aSet, char16_t aNewChar )
|
||||
{
|
||||
if (!EnsureMutable()) // XXX do this lazily?
|
||||
NS_ABORT_OOM(mLength);
|
||||
|
||||
char16_t* data = mData;
|
||||
uint32_t lenRemaining = mLength;
|
||||
|
||||
while (lenRemaining)
|
||||
{
|
||||
int32_t i = ::FindCharInSet(data, lenRemaining, aSet);
|
||||
if (i == kNotFound)
|
||||
break;
|
||||
|
||||
data[i++] = aNewChar;
|
||||
data += i;
|
||||
lenRemaining -= i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nsTString::Compare,CompareWithConversion,etc.
|
||||
|
Loading…
Reference in New Issue
Block a user