Skip to content

Commit

Permalink
perf: User Map to optimize performance (#4122)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
zhihuahuang and lukastaegert committed Jun 6, 2021
1 parent d985955 commit 172c114
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/collapseSourcemaps.ts
Expand Up @@ -50,6 +50,7 @@ class Link {
const sources: string[] = [];
const sourcesContent: string[] = [];
const names: string[] = [];
const nameIndexMap: Map<string, number> = new Map();

const mappings = [];

Expand Down Expand Up @@ -93,10 +94,11 @@ class Link {
];

if (traced.name) {
let nameIndex = names.indexOf(traced.name);
if (nameIndex === -1) {
let nameIndex = nameIndexMap.get(traced.name);
if (nameIndex === undefined) {
nameIndex = names.length;
names.push(traced.name);
nameIndexMap.set(traced.name, nameIndex);
}

(tracedSegment as SourceMapSegment)[4] = nameIndex;
Expand Down

0 comments on commit 172c114

Please sign in to comment.