Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: src/v8natives.js

Issue 7830036: Optimize isFinite and isNaN. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 2039fea2766316f7bfa9f4038b115df734d11ac4..6e8d5bbad33ccf1c92ffa0bb6bc83ab456534a4a 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -41,7 +41,6 @@
const $isNaN = GlobalIsNaN;
const $isFinite = GlobalIsFinite;
PhistucK 2011/09/02 20:24:34 I know this code was there already, but see http:/
Lasse Reichstein 2011/09/05 10:51:16 We shouldn't use "const" at all. The primary reaso
-
// ----------------------------------------------------------------------------
@@ -86,17 +85,15 @@ function InstallFunctionsOnHiddenPrototype(object, attributes, functions) {
// ECMA 262 - 15.1.4
function GlobalIsNaN(number) {
- var n = ToNumber(number);
- return NUMBER_IS_NAN(n);
+ if (!IS_NUMBER(number)) number = NonNumberToNumber(number);
+ return NUMBER_IS_NAN(number);
}
// ECMA 262 - 15.1.5
function GlobalIsFinite(number) {
if (!IS_NUMBER(number)) number = NonNumberToNumber(number);
-
- // NaN - NaN == NaN, Infinity - Infinity == NaN, -Infinity - -Infinity == NaN.
- return %_IsSmi(number) || number - number == 0;
+ return !NUMBER_IS_NAN(number) && number !== (1 / 0) && number !== (-1 / 0);
Sven Panne 2011/09/02 16:00:14 !NUMBER_IS_NAN(number) is equivalent to %_IsSmi(%I
Lasse Reichstein 2011/09/05 10:51:16 That depends a lot on the test. My, admittedly ver
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698