Skip to content

Commit

Permalink
Optimize slice last sharp tail (yarnpkg#7353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha authored and VincentBailly committed Jun 10, 2020
1 parent ea87d07 commit 84f1d07
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export async function buildTree(
}

export function getParent(key: string, treesByKey: Object): Object {
const parentKey = key.split('#').slice(0, -1).join('#');
const parentKey = key.slice(0, key.lastIndexOf('#'));
return treesByKey[parentKey];
}

Expand Down
2 changes: 1 addition & 1 deletion src/hoisted-tree-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type HoistedTree = {
export type HoistedTrees = Array<HoistedTree>;

export function getParent(key: string, treesByKey: Object): Object {
const parentKey = key.split('#').slice(0, -1).join('#');
const parentKey = key.slice(0, key.lastIndexOf('#'));
return treesByKey[parentKey];
}

Expand Down

0 comments on commit 84f1d07

Please sign in to comment.