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

cmd/compile: use (*strings.Reader).Reset

Since when go1.17 is now used for bootstraping.

Change-Id: If28338fc82e6c61f057d7eb3a4c2ed77846167df
Reviewed-on: https://go-review.googlesource.com/c/go/+/427558
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
This commit is contained in:
hopehook 2022-09-01 22:59:05 +08:00 committed by Matthew Dempsky
parent dced3461ee
commit 1e7f535475
2 changed files with 3 additions and 11 deletions

View File

@ -233,10 +233,7 @@ func (p *iimporter) doDecl(pkg *types2.Package, name string) {
}
r := &importReader{p: p, currPkg: pkg}
// Reader.Reset is not available in Go 1.4.
// Use bytes.NewReader for now.
// r.declReader.Reset(p.declData[off:])
r.declReader = *strings.NewReader(p.declData[off:])
r.declReader.Reset(p.declData[off:])
r.obj(name)
}
@ -282,10 +279,7 @@ func (p *iimporter) typAt(off uint64, base *types2.Named) types2.Type {
}
r := &importReader{p: p}
// Reader.Reset is not available in Go 1.4.
// Use bytes.NewReader for now.
// r.declReader.Reset(p.declData[off-predeclReserved:])
r.declReader = *strings.NewReader(p.declData[off-predeclReserved:])
r.declReader.Reset(p.declData[off-predeclReserved:])
t := r.doType(base)
if canReuse(base, t) {

View File

@ -280,9 +280,7 @@ func (p *iimporter) newReader(off uint64, pkg *types.Pkg) *importReader {
p: p,
currPkg: pkg,
}
// (*strings.Reader).Reset wasn't added until Go 1.7, and we
// need to build with Go 1.4.
r.Reader = *strings.NewReader(p.declData[off:])
r.Reader.Reset(p.declData[off:])
return r
}