mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-03-03 12:58:03 +01:00
Update BasicAdapter to use strtod instead of istringstream for string-to-double conversions
This commit is contained in:
parent
dc8ad3669e
commit
6b8a394cbf
@ -330,13 +330,14 @@ public:
|
||||
} else if (value.isString()) {
|
||||
std::string s;
|
||||
if (value.getString(s)) {
|
||||
std::istringstream i(s);
|
||||
double x;
|
||||
char c;
|
||||
if (!(!(i >> x) || i.get(c))) {
|
||||
result = x;
|
||||
return true;
|
||||
const char *b = s.c_str();
|
||||
char *e = NULL;
|
||||
double x = strtod(b, &e);
|
||||
if (e == b || e != b + s.length()) {
|
||||
return false;
|
||||
}
|
||||
result = x;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -753,13 +754,10 @@ public:
|
||||
} else if (value.isString()) {
|
||||
std::string s;
|
||||
if (value.getString(s)) {
|
||||
std::istringstream i(s);
|
||||
double x;
|
||||
char c;
|
||||
if (!(i >> x) || i.get(c)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
const char *b = s.c_str();
|
||||
char *e = NULL;
|
||||
strtod(b, &e);
|
||||
return e != b && e == b + s.length();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user