mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-15 06:39:17 +00:00
perf(packages/codegen): take named-mapping only code off hot path in recordSourceMapping (#25883)
Follow-on after #25585. Small optimization. `name` can only be `!== undefined` when `location === false`. So move that logic into that block, removing a branch from the fast path.
This commit is contained in:
1 parent
a734af5347
commit
f720f15b62
1 file changed
+6
-6
@@ -431,8 +431,8 @@ function recordSourceMapping(state: State, node: MappableNode, location: false |
|
||||
// recovering a name or retaining the mapping, since member-level marks commonly duplicate keys.
|
||||
if (state.mapPositions[state.mapPositions.length - 1] === sourceOffset) return;
|
||||
|
||||
let name: string | undefined;
|
||||
if (location === false) {
|
||||
let name: string | undefined;
|
||||
const printedName = typeof node.name === "string" ? node.name : undefined;
|
||||
if (printedName !== undefined) {
|
||||
// Almost every identifier is printed exactly as it appeared in the source. Avoid scanning it
|
||||
@@ -458,14 +458,14 @@ function recordSourceMapping(state: State, node: MappableNode, location: false |
|
||||
} else {
|
||||
name = printedName;
|
||||
}
|
||||
|
||||
if (name !== undefined) {
|
||||
const mappingIndex = state.mapPositions.length >> 1;
|
||||
(state.mapNames ??= []).push(mappingIndex, name);
|
||||
}
|
||||
}
|
||||
|
||||
const mappingIndex = state.mapPositions.length >> 1;
|
||||
state.mapPositions.push(state.output.length, sourceOffset);
|
||||
|
||||
if (name !== undefined) {
|
||||
(state.mapNames ??= []).push(mappingIndex, name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user