Fix performance of parsing Mints.

Review URL: https://codereview.chromium.org//13852044

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21767 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
srdjan@google.com 2013-04-19 20:22:26 +00:00
parent 6c60285f23
commit cc94080d4d
2 changed files with 9 additions and 3 deletions

View file

@ -193,10 +193,10 @@ DEFINE_NATIVE_ENTRY(Integer_parse, 1) {
// a) '+5' is not a valid integer (leading plus).
if (cstr[0] != '+') {
char* p_end = NULL;
const int64_t int_value = strtol(cstr, &p_end, 10);
const int64_t int_value = strtoll(cstr, &p_end, 10);
if (p_end == (cstr + len)) {
if ((Smi::kMinValue <= int_value) && (int_value <= Smi::kMaxValue)) {
return Smi::New(int_value);
if ((int_value != LLONG_MIN) && (int_value != LLONG_MAX)) {
return Integer::New(int_value);
}
}
}

View file

@ -65,4 +65,10 @@ static inline double round(double x) {
}
}
// Windows does not have strtoll defined.
#if defined(_MSC_VER)
#define strtoll _strtoi64
#endif
#endif // PLATFORM_C99_SUPPORT_WIN_H_