Skip to content

Commit 145bd33

Browse files
committed
feat: drop lodash.keys (~7% speedup)
1 parent ac4c570 commit 145bd33

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"lodash.isequal": "^4.5.0",
5858
"lodash.isfunction": "^3.0.9",
5959
"lodash.isundefined": "^3.0.1",
60-
"lodash.keys": "^4.2.0",
6160
"lodash.map": "^4.6.0",
6261
"lodash.reduce": "^4.6.0",
6362
"lodash.size": "^4.2.0",

src/core/dep-graph.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ class DepGraphImpl implements types.DepGraphInternal {
347347

348348
const pathsFromNodeToRoot = this.pathsFromNodeToRoot(id, ancestors, opts);
349349

350-
pathsFromNodeToRoot.forEach((path) =>
351-
allPaths.push([pkgInfo].concat(path)),
352-
);
350+
for (const path of pathsFromNodeToRoot) {
351+
allPaths.push([pkgInfo].concat(path));
352+
}
353353

354354
if (limit && allPaths.length >= limit) {
355355
break;

src/graphlib/graph.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as _filter from 'lodash.foreach';
66
import * as isEmpty from 'lodash.isempty';
77
import * as isFunction from 'lodash.isfunction';
88
import * as isUndefined from 'lodash.isundefined';
9-
import * as keys from 'lodash.keys';
109
import * as reduce from 'lodash.reduce';
1110
import * as union from 'lodash.union';
1211
import * as values from 'lodash.values';
@@ -148,7 +147,7 @@ export class Graph {
148147
}
149148

150149
nodes() {
151-
return keys(this._nodes);
150+
return Object.keys(this._nodes);
152151
}
153152

154153
sources() {
@@ -223,10 +222,10 @@ export class Graph {
223222
});
224223
delete this._children[v];
225224
}
226-
each(keys(this._in[v]), removeEdge);
225+
each(Object.keys(this._in[v]), removeEdge);
227226
delete this._in[v];
228227
delete this._preds[v];
229-
each(keys(this._out[v]), removeEdge);
228+
each(Object.keys(this._out[v]), removeEdge);
230229
delete this._out[v];
231230
delete this._sucs[v];
232231
--this._nodeCount;
@@ -291,7 +290,7 @@ export class Graph {
291290
if (this._isCompound) {
292291
const children = this._children[v];
293292
if (children) {
294-
return keys(children);
293+
return Object.keys(children);
295294
}
296295
} else if (v === GRAPH_NODE) {
297296
return this.nodes();
@@ -303,14 +302,14 @@ export class Graph {
303302
predecessors(v) {
304303
const predsV = this._preds[v];
305304
if (predsV) {
306-
return keys(predsV);
305+
return Object.keys(predsV);
307306
}
308307
}
309308

310309
successors(v) {
311310
const sucsV = this._sucs[v];
312311
if (sucsV) {
313-
return keys(sucsV);
312+
return Object.keys(sucsV);
314313
}
315314
}
316315

0 commit comments

Comments
 (0)