From 1e7f535475febc247c9e27249ee35e3a00dfa769 Mon Sep 17 00:00:00 2001 From: hopehook Date: Thu, 1 Sep 2022 22:59:05 +0800 Subject: [PATCH] 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 Reviewed-by: Keith Randall Auto-Submit: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Heschi Kreinick Run-TryBot: hopehook --- src/cmd/compile/internal/importer/iimport.go | 10 ++-------- src/cmd/compile/internal/typecheck/iimport.go | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/cmd/compile/internal/importer/iimport.go b/src/cmd/compile/internal/importer/iimport.go index 440f557a80d..82aff183354 100644 --- a/src/cmd/compile/internal/importer/iimport.go +++ b/src/cmd/compile/internal/importer/iimport.go @@ -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) { diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index a08f62b4146..80ae0259e86 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -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 }