diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 95999c947b..9f078e44e8 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -137,6 +137,7 @@ type Printer struct { nameGenerator NameGenerator makeFileLevelOptimisticUniqueName func(string) string commentStatePool core.Pool[commentState] + sourceMapStatePool core.Pool[sourceMapState] } type detachedCommentsInfo struct { @@ -5489,7 +5490,9 @@ func (p *Printer) emitSourceMapsBeforeNode(node *ast.Node) *sourceMapState { p.sourceMapsDisabled = true } - return &sourceMapState{emitFlags, loc, false} + state := p.sourceMapStatePool.New() + *state = sourceMapState{emitFlags, loc, false} + return state } func (p *Printer) emitSourceMapsAfterNode(node *ast.Node, previousState *sourceMapState) { @@ -5527,7 +5530,9 @@ func (p *Printer) emitSourceMapsBeforeToken(token ast.Kind, pos int, contextNode } } - return &sourceMapState{emitFlags, loc, hasLoc} + state := p.sourceMapStatePool.New() + *state = sourceMapState{emitFlags, loc, hasLoc} + return state } func (p *Printer) emitSourceMapsAfterToken(token ast.Kind, pos int, contextNode *ast.Node, previousState *sourceMapState) {