OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 function GlobalIsFinite(number) { | 85 function GlobalIsFinite(number) { |
86 if (!IS_NUMBER(number)) number = NonNumberToNumber(number); | 86 if (!IS_NUMBER(number)) number = NonNumberToNumber(number); |
87 | 87 |
88 // NaN - NaN == NaN, Infinity - Infinity == NaN, -Infinity - -Infinity == NaN. | 88 // NaN - NaN == NaN, Infinity - Infinity == NaN, -Infinity - -Infinity == NaN. |
89 return %_IsSmi(number) || number - number == 0; | 89 return %_IsSmi(number) || number - number == 0; |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 // ECMA-262 - 15.1.2.2 | 93 // ECMA-262 - 15.1.2.2 |
94 function GlobalParseInt(string, radix) { | 94 function GlobalParseInt(string, radix) { |
95 if (IS_UNDEFINED(radix)) { | 95 if (IS_UNDEFINED(radix) || radix == 10 || radix == 0) { |
Erik Corry
2011/02/22 08:53:05
I think you want === here.
Mads Ager (chromium)
2011/02/22 08:53:55
Erik suggests using === here. I agree with that an
sandholm
2011/02/22 08:59:57
Done.
sandholm
2011/02/22 08:59:57
Done.
| |
96 // Some people use parseInt instead of Math.floor. This | 96 // Some people use parseInt instead of Math.floor. This |
97 // optimization makes parseInt on a Smi 12 times faster (60ns | 97 // optimization makes parseInt on a Smi 12 times faster (60ns |
98 // vs 800ns). The following optimization makes parseInt on a | 98 // vs 800ns). The following optimization makes parseInt on a |
99 // non-Smi number 9 times faster (230ns vs 2070ns). Together | 99 // non-Smi number 9 times faster (230ns vs 2070ns). Together |
100 // they make parseInt on a string 1.4% slower (274ns vs 270ns). | 100 // they make parseInt on a string 1.4% slower (274ns vs 270ns). |
101 if (%_IsSmi(string)) return string; | 101 if (%_IsSmi(string)) return string; |
102 if (IS_NUMBER(string) && | 102 if (IS_NUMBER(string) && |
103 ((0.01 < string && string < 1e9) || | 103 ((0.01 < string && string < 1e9) || |
104 (-1e9 < string && string < -0.01))) { | 104 (-1e9 < string && string < -0.01))) { |
105 // Truncate number. | 105 // Truncate number. |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1243 // ---------------------------------------------------------------------------- | 1243 // ---------------------------------------------------------------------------- |
1244 | 1244 |
1245 function SetupFunction() { | 1245 function SetupFunction() { |
1246 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1246 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1247 "bind", FunctionBind, | 1247 "bind", FunctionBind, |
1248 "toString", FunctionToString | 1248 "toString", FunctionToString |
1249 )); | 1249 )); |
1250 } | 1250 } |
1251 | 1251 |
1252 SetupFunction(); | 1252 SetupFunction(); |
OLD | NEW |