add specialized StringToInt32 and filter for it

This commit is contained in:
2008-07-31 11:35:08 -07:00
parent fff1140141
commit 8113986178
3 changed files with 22 additions and 1 deletions

View File

@@ -239,7 +239,7 @@ builtin_EqualStrings(JSString* str1, JSString* str2)
}
jsdouble FASTCALL
builtin_StringToNumber(JSContext* cx, JSString *str)
builtin_StringToNumber(JSContext* cx, JSString* str)
{
const jschar* bp;
const jschar* end;
@@ -256,6 +256,20 @@ builtin_StringToNumber(JSContext* cx, JSString *str)
return d;
}
jsint FASTCALL
builtin_StringToInt32(JSContext* cx, JSString* str)
{
const jschar* bp;
const jschar* end;
const jschar* ep;
jsdouble d;
JSSTRING_CHARS_AND_END(str, bp, end);
if (!js_strtod(cx, bp, end, &ep, &d) || js_SkipWhiteSpace(ep, end) != end)
return 0;
return (jsint)d;
}
#define LO ARGSIZE_LO
#define F ARGSIZE_F
#define Q ARGSIZE_Q