1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-26 02:14:22 +00:00

tidied up String::replaceFirstOccurrenceOf() method

This commit is contained in:
ed 2017-02-07 12:25:08 +00:00
parent 3cef6dcbdf
commit e7ebd069e3

View file

@ -1328,12 +1328,11 @@ String String::replace (StringRef stringToReplace, StringRef stringToInsert, con
String String::replaceFirstOccurrenceOf (StringRef stringToReplace, StringRef stringToInsert, const bool ignoreCase) const
{
const int stringToReplaceLen = stringToReplace.length();
const int index = ignoreCase ? indexOfIgnoreCase (stringToReplace)
: indexOf (stringToReplace);
int i = 0;
if ((i = (ignoreCase ? indexOfIgnoreCase (stringToReplace)
: indexOf (stringToReplace))) >= 0)
return replaceSection (i, stringToReplaceLen, stringToInsert);
if (index >= 0)
return replaceSection (index, stringToReplaceLen, stringToInsert);
return *this;
}