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

Unified Diff: src/v8natives.js

Issue 6061008: Avoid double checking for IS_NUMBER by calling NonNumToNum instead of ToNumbe... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 12 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
« src/math.js ('K') | « src/runtime.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
===================================================================
--- src/v8natives.js (revision 6174)
+++ src/v8natives.js (working copy)
@@ -83,7 +83,7 @@
// ECMA 262 - 15.1.5
function GlobalIsFinite(number) {
- if (!IS_NUMBER(number)) number = ToNumber(number);
+ if (!IS_NUMBER(number)) number = NonNumToNum(number);
// NaN - NaN == NaN, Infinity - Infinity == NaN, -Infinity - -Infinity == NaN.
return %_IsSmi(number) || number - number == 0;
@@ -896,9 +896,14 @@
function BooleanToString() {
// NOTE: Both Boolean objects and values can enter here as
// 'this'. This is not as dictated by ECMA-262.
- if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this))
- throw new $TypeError('Boolean.prototype.toString is not generic');
- return ToString(%_ValueOf(this));
+ var b = this;
+ if (!IS_BOOLEAN(b)) {
+ if (!IS_BOOLEAN_WRAPPER(b)) {
+ throw new $TypeError('Boolean.prototype.toString is not generic');
+ }
+ b = %_ValueOf(b);
+ }
+ return b ? 'true' : 'false';
}
@@ -951,7 +956,7 @@
}
// Fast case: Convert number in radix 10.
if (IS_UNDEFINED(radix) || radix === 10) {
- return ToString(number);
+ return %_NumberToString(number);
}
// Convert the radix to an integer and check the range.
@@ -1150,11 +1155,8 @@
var p = '';
if (n > 1) {
p = new $Array(n - 1);
- // Explicitly convert all parameters to strings.
- // Array.prototype.join replaces null with empty strings which is
- // not appropriate.
- for (var i = 0; i < n - 1; i++) p[i] = ToString(%_Arguments(i));
- p = p.join(',');
+ for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i);
+ p = Join(p, n - 1, ',', ToString);
// If the formal parameters string include ) - an illegal
// character - it may make the combined function expression
// compile. We avoid this problem by checking for this early on.
« src/math.js ('K') | « src/runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698