Optimize json parsing (#3480)

This commit is contained in:
ctrlaltca 2018-12-31 01:05:40 +01:00 committed by Zach H
parent 40f787be14
commit 2621cc09ac

View file

@ -503,11 +503,12 @@ QVariant Json::parseNumber(const QString &json, int &index)
*/ */
int Json::lastIndexOfNumber(const QString &json, int index) int Json::lastIndexOfNumber(const QString &json, int index)
{ {
static const QString numericCharacters("0123456789+-.eE");
int lastIndex; int lastIndex;
for(lastIndex = index; lastIndex < json.size(); lastIndex++) for(lastIndex = index; lastIndex < json.size(); lastIndex++)
{ {
if(QString("0123456789+-.eE").indexOf(json[lastIndex]) == -1) if(numericCharacters.indexOf(json[lastIndex]) == -1)
{ {
break; break;
} }
@ -521,9 +522,10 @@ int Json::lastIndexOfNumber(const QString &json, int index)
*/ */
void Json::eatWhitespace(const QString &json, int &index) void Json::eatWhitespace(const QString &json, int &index)
{ {
static const QString whitespaceChars(" \t\n\r");
for(; index < json.size(); index++) for(; index < json.size(); index++)
{ {
if(QString(" \t\n\r").indexOf(json[index]) == -1) if(whitespaceChars.indexOf(json[index]) == -1)
{ {
break; break;
} }