mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
Optimize json parsing (#3480)
This commit is contained in:
parent
40f787be14
commit
2621cc09ac
1 changed files with 16 additions and 14 deletions
|
|
@ -503,11 +503,12 @@ QVariant Json::parseNumber(const QString &json, int &index)
|
|||
*/
|
||||
int Json::lastIndexOfNumber(const QString &json, int index)
|
||||
{
|
||||
static const QString numericCharacters("0123456789+-.eE");
|
||||
int lastIndex;
|
||||
|
||||
for(lastIndex = index; lastIndex < json.size(); lastIndex++)
|
||||
{
|
||||
if(QString("0123456789+-.eE").indexOf(json[lastIndex]) == -1)
|
||||
if(numericCharacters.indexOf(json[lastIndex]) == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -521,9 +522,10 @@ int Json::lastIndexOfNumber(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++)
|
||||
{
|
||||
if(QString(" \t\n\r").indexOf(json[index]) == -1)
|
||||
if(whitespaceChars.indexOf(json[index]) == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue