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

Unified Diff: src/array.js

Issue 5614004: Use the PushIfAbsent function for the JSON stringify stack.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years 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 | src/json.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
===================================================================
--- src/array.js (revision 5940)
+++ src/array.js (working copy)
@@ -159,25 +159,23 @@
}
-function ConvertToString(e) {
- if (e == null) return '';
- else return ToString(e);
+function ConvertToString(x) {
+ if (IS_STRING(x)) return x;
+ if (IS_NUMBER(x)) return %_NumberToString(x);
+ if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
+ return (IS_NULL_OR_UNDEFINED(x)) ? '' : %ToString(%DefaultString(x));
}
function ConvertToLocaleString(e) {
- if (e == null) {
- return '';
- } else {
- // e_obj's toLocaleString might be overwritten, check if it is a function.
- // Call ToString if toLocaleString is not a function.
- // See issue 877615.
- var e_obj = ToObject(e);
- if (IS_FUNCTION(e_obj.toLocaleString))
- return ToString(e_obj.toLocaleString());
- else
- return ToString(e);
- }
+ // e_obj's toLocaleString might be overwritten, check if it is a function.
+ // Call ConvertToString if toLocaleString is not a function.
+ // See issue 877615.
+ var e_obj = ToObject(e);
+ if (IS_FUNCTION(e_obj.toLocaleString))
+ return ToString(e_obj.toLocaleString());
+ else
+ return ConvertToString(e);
}
@@ -365,14 +363,13 @@
if (IS_UNDEFINED(separator)) {
separator = ',';
} else if (!IS_STRING(separator)) {
- separator = ToString(separator);
+ separator = NonStringToString(separator);
}
var result = %_FastAsciiArrayJoin(this, separator);
if (!IS_UNDEFINED(result)) return result;
- var length = TO_UINT32(this.length);
- return Join(this, length, separator, ConvertToString);
+ return Join(this, TO_UINT32(this.length), separator, ConvertToString);
}
« no previous file with comments | « no previous file | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698