Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 7a6a44c

Browse files
committed
Remove lodash usage from ObjectInspector util.
Lodash functions were used in an hot function and was taking significant amount of time (~80ms). Using plain js does not make the code too bad and shaves of dozen of millisecond (~25ms).
1 parent 1aa4499 commit 7a6a44c

File tree

1 file changed

+10
-7
lines changed
  • packages/devtools-reps/src/object-inspector/utils

1 file changed

+10
-7
lines changed

packages/devtools-reps/src/object-inspector/utils/node.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// @flow
66

7-
const { get, has } = require("lodash");
87
const { maybeEscapePropertyName } = require("../../reps/rep-utils");
98
const ArrayRep = require("../../reps/array");
109
const GripArrayRep = require("../../reps/grip-array");
@@ -55,12 +54,12 @@ function getType(item: Node) : Symbol {
5554
function getValue(
5655
item: Node
5756
) : RdpGrip | NodeContents {
58-
if (has(item, "contents.value")) {
59-
return get(item, "contents.value");
57+
if (item && item.contents && item.contents.hasOwnProperty("value")) {
58+
return item.contents.value;
6059
}
6160

62-
if (has(item, "contents.getterValue")) {
63-
return get(item, "contents.getterValue", undefined);
61+
if (item && item.contents && item.contents.hasOwnProperty("getterValue")) {
62+
return item.contents.getterValue;
6463
}
6564

6665
if (nodeHasAccessors(item)) {
@@ -419,11 +418,15 @@ function makeNodesForMapEntry(
419418
}
420419

421420
function getNodeGetter(item: Node): ?Object {
422-
return get(item, "contents.get", undefined);
421+
return item && item.contents
422+
? item.contents.get
423+
: undefined;
423424
}
424425

425426
function getNodeSetter(item: Node): ?Object {
426-
return get(item, "contents.set", undefined);
427+
return item && item.contents
428+
? item.contents.set
429+
: undefined;
427430
}
428431

429432
function makeNodesForAccessors(item: Node) : Array<Node> {

0 commit comments

Comments
 (0)