1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:50:06 -07:00

Revert "go/printer: reuse go/token.FileSet.PositionFor calls in setPos"

This reverts commit http://go.dev/cl/461739

Reason for revert: Causes longtest failures due to odd formatting.

Change-Id: I7e31ff107e730b6d667866ea7718bc8632760422
Reviewed-on: https://go-review.googlesource.com/c/go/+/483676
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Than McIntosh 2023-04-11 14:15:36 +00:00
parent e78871ea07
commit 267b50a834

View File

@ -878,12 +878,8 @@ func mayCombine(prev token.Token, next byte) (b bool) {
}
func (p *printer) setPos(pos token.Pos) {
// If p.pos is already equivalent to pos,
// we can avoid calling posFor again.
if pos.IsValid() {
if file := p.fset.File(pos); file != nil && file.Offset(pos) != p.pos.Offset {
p.pos = p.posFor(pos) // accurate position of next item
}
p.pos = p.posFor(pos) // accurate position of next item
}
}