do not convert to stdString expensively when parsing ordered json numbers
This commit is contained in:
parent
4df4e6ddd7
commit
f1b962bdf5
1 changed files with 4 additions and 2 deletions
|
@ -631,7 +631,8 @@ struct JsonParser final {
|
||||||
|
|
||||||
if (str[i] != '.' && str[i] != 'e' && str[i] != 'E'
|
if (str[i] != '.' && str[i] != 'e' && str[i] != 'E'
|
||||||
&& (i - start_pos) <= static_cast<unsigned>(std::numeric_limits<int>::digits10)) {
|
&& (i - start_pos) <= static_cast<unsigned>(std::numeric_limits<int>::digits10)) {
|
||||||
return std::atoi(str.toStdString().c_str() + start_pos);
|
bool ok;
|
||||||
|
return str.mid(start_pos, i - start_pos).toInt(&ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decimal part
|
// Decimal part
|
||||||
|
@ -658,7 +659,8 @@ struct JsonParser final {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::strtod(str.toStdString().c_str() + start_pos, nullptr);
|
bool ok;
|
||||||
|
return str.mid(start_pos, i - start_pos).toDouble(&ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* expect(str, res)
|
/* expect(str, res)
|
||||||
|
|
Loading…
Reference in a new issue