Browse Source

fix: skip unnecessary checks/calls in jsonDump

tophf 4 years ago
parent
commit
76e47a5ff3
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/injected/web/util-web.js

+ 4 - 4
src/injected/web/util-web.js

@@ -42,12 +42,12 @@ export const jsonDump = (value, stack) => {
     break;
   case 'object':
     if (!stack) {
-      stack = []; // Creating the array here, only when type is object.
-    }
-    if (stack::indexOf(value) >= 0) {
+      stack = [value]; // Creating the array here, only when type is object.
+    } else if (stack::indexOf(value) >= 0) {
       throw new ErrorSafe('Converting circular structure to JSON');
+    } else {
+      setOwnProp(stack, stack.length, value);
     }
-    setOwnProp(stack, stack.length, value);
     if (ArrayIsArray(value)) {
       res = '[';
       // Must enumerate all values to include holes in sparse arrays