Directly use %ObjectKeys in json stringify.
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 3 Sep 2012 08:37:47 +0000 (08:37 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 3 Sep 2012 08:37:47 +0000 (08:37 +0000)
BUG=2312

Review URL: https://chromiumcodereview.appspot.com/10905059

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12424 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/json.js

index ccef4456d690526379dae54c31dd8fe3b550c87f..85224b0f053ffde051228ae9f66de947009db402 100644 (file)
@@ -247,22 +247,23 @@ function BasicSerializeObject(value, stack, builder) {
   }
   builder.push("{");
   var first = true;
-  for (var p in value) {
-    if (%HasLocalProperty(value, p)) {
-      if (!first) {
-        builder.push(%QuoteJSONStringComma(p));
-      } else {
-        builder.push(%QuoteJSONString(p));
-      }
-      builder.push(":");
-      var before = builder.length;
-      BasicJSONSerialize(p, value[p], stack, builder);
-      if (before == builder.length) {
-        builder.pop();
-        builder.pop();
-      } else {
-        first = false;
-      }
+  var keys = %ObjectKeys(value);
+  var len = keys.length;
+  for (var i = 0; i < len; i++) {
+    var p = keys[i];
+    if (!first) {
+      builder.push(%QuoteJSONStringComma(p));
+    } else {
+      builder.push(%QuoteJSONString(p));
+    }
+    builder.push(":");
+    var before = builder.length;
+    BasicJSONSerialize(p, value[p], stack, builder);
+    if (before == builder.length) {
+      builder.pop();
+      builder.pop();
+    } else {
+      first = false;
     }
   }
   stack.pop();