Skip to content

Commit dbe69bd

Browse files
authored
Pool sourceMapState tool (#1320)
1 parent cacd61b commit dbe69bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/printer/printer.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ type Printer struct {
137137
nameGenerator NameGenerator
138138
makeFileLevelOptimisticUniqueName func(string) string
139139
commentStatePool core.Pool[commentState]
140+
sourceMapStatePool core.Pool[sourceMapState]
140141
}
141142

142143
type detachedCommentsInfo struct {
@@ -5489,7 +5490,9 @@ func (p *Printer) emitSourceMapsBeforeNode(node *ast.Node) *sourceMapState {
54895490
p.sourceMapsDisabled = true
54905491
}
54915492

5492-
return &sourceMapState{emitFlags, loc, false}
5493+
state := p.sourceMapStatePool.New()
5494+
*state = sourceMapState{emitFlags, loc, false}
5495+
return state
54935496
}
54945497

54955498
func (p *Printer) emitSourceMapsAfterNode(node *ast.Node, previousState *sourceMapState) {
@@ -5527,7 +5530,9 @@ func (p *Printer) emitSourceMapsBeforeToken(token ast.Kind, pos int, contextNode
55275530
}
55285531
}
55295532

5530-
return &sourceMapState{emitFlags, loc, hasLoc}
5533+
state := p.sourceMapStatePool.New()
5534+
*state = sourceMapState{emitFlags, loc, hasLoc}
5535+
return state
55315536
}
55325537

55335538
func (p *Printer) emitSourceMapsAfterToken(token ast.Kind, pos int, contextNode *ast.Node, previousState *sourceMapState) {

0 commit comments

Comments
 (0)