mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Minor optimisations to StringArray.
This commit is contained in:
parent
ebb7b6db74
commit
d7825c23fe
1 changed files with 11 additions and 24 deletions
|
|
@ -371,7 +371,7 @@ int StringArray::addTokens (const String& text, const String& breakCharacters, c
|
|||
String::CharPointerType tokenEnd (CharacterFunctions::findEndOfToken (t,
|
||||
breakCharacters.getCharPointer(),
|
||||
quoteCharacters.getCharPointer()));
|
||||
add (String (t, tokenEnd));
|
||||
strings.add (String (t, tokenEnd));
|
||||
++num;
|
||||
|
||||
if (tokenEnd.isEmpty())
|
||||
|
|
@ -392,35 +392,22 @@ int StringArray::addLines (const String& sourceText)
|
|||
|
||||
while (! finished)
|
||||
{
|
||||
String::CharPointerType startOfLine (text);
|
||||
size_t numChars = 0;
|
||||
|
||||
for (;;)
|
||||
for (String::CharPointerType startOfLine (text);;)
|
||||
{
|
||||
const juce_wchar c = text.getAndAdvance();
|
||||
const String::CharPointerType endOfLine (text);
|
||||
|
||||
if (c == 0)
|
||||
switch (text.getAndAdvance())
|
||||
{
|
||||
finished = true;
|
||||
break;
|
||||
case 0: finished = true; break;
|
||||
case '\n': break;
|
||||
case '\r': if (*text == '\n') ++text; break;
|
||||
default: continue;
|
||||
}
|
||||
|
||||
if (c == '\n')
|
||||
break;
|
||||
|
||||
if (c == '\r')
|
||||
{
|
||||
if (*text == '\n')
|
||||
++text;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++numChars;
|
||||
strings.add (String (startOfLine, endOfLine));
|
||||
++numLines;
|
||||
break;
|
||||
}
|
||||
|
||||
add (String (startOfLine, numChars));
|
||||
++numLines;
|
||||
}
|
||||
|
||||
return numLines;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue