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

Unified Diff: src/js/json.js

Issue 1785003004: Revert of Replace PushIfAbsent by a Stack object and move StringBuilderJoin to JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/js/array.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/json.js
diff --git a/src/js/json.js b/src/js/json.js
index c6dbed9cbbf7f0923bc446387f6f9c7f700f8d27..ddd081bab11bf7dfa5c0fcef7385c247e56443f3 100644
--- a/src/js/json.js
+++ b/src/js/json.js
@@ -19,10 +19,6 @@
var MaxSimple;
var MinSimple;
var ObjectHasOwnProperty;
-var Stack;
-var StackHas;
-var StackPop;
-var StackPush;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
@@ -30,10 +26,6 @@
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
- Stack = from.Stack;
- StackHas = from.StackHas;
- StackPop = from.StackPop;
- StackPush = from.StackPush;
});
// -------------------------------------------------------------------
@@ -86,8 +78,7 @@
function SerializeArray(value, replacer, stack, indent, gap) {
- if (StackHas(stack, value)) throw MakeTypeError(kCircularStructure);
- StackPush(stack, value);
+ if (!%PushIfAbsent(stack, value)) throw MakeTypeError(kCircularStructure);
var stepback = indent;
indent += gap;
var partial = new InternalArray();
@@ -110,14 +101,13 @@
} else {
final = "[]";
}
- StackPop(stack);
+ stack.pop();
return final;
}
function SerializeObject(value, replacer, stack, indent, gap) {
- if (StackHas(stack, value)) throw MakeTypeError(kCircularStructure);
- StackPush(stack, value);
+ if (!%PushIfAbsent(stack, value)) throw MakeTypeError(kCircularStructure);
var stepback = indent;
indent += gap;
var partial = new InternalArray();
@@ -156,7 +146,7 @@
} else {
final = "{}";
}
- StackPop(stack);
+ stack.pop();
return final;
}
@@ -251,7 +241,7 @@
if (!IS_CALLABLE(replacer) && !property_list && !gap && !IS_PROXY(value)) {
return %BasicJSONStringify(value);
}
- return JSONSerialize('', {'': value}, replacer, new Stack(), "", gap);
+ return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap);
}
// -------------------------------------------------------------------
@@ -289,7 +279,7 @@
var holder = {};
holder[key] = object;
// No need to pass the actual holder since there is no replacer function.
- return JSONSerialize(key, holder, UNDEFINED, new Stack(), "", "");
+ return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
}
%InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]);
« no previous file with comments | « src/js/array.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698