all: clean up TODO after fixing issue 44505

For #44505

Change-Id: I89220be02372b5340cb987bf2ac870a9346a8c8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/421079
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
hopehook 2022-08-04 10:12:20 +08:00 committed by Matthew Dempsky
parent 39728f412d
commit 91d5ce3def
5 changed files with 11 additions and 12 deletions

View File

@ -5,6 +5,7 @@
package lex package lex
import ( import (
"go/build/constraint"
"io" "io"
"os" "os"
"strings" "strings"
@ -109,8 +110,7 @@ func (t *Tokenizer) Next() ScanToken {
} }
text := s.TokenText() text := s.TokenText()
t.line += strings.Count(text, "\n") t.line += strings.Count(text, "\n")
// TODO: Use constraint.IsGoBuild once #44505 fixed. if constraint.IsGoBuild(text) {
if strings.HasPrefix(text, "//go:build") {
t.tok = BuildComment t.tok = BuildComment
break break
} }

View File

@ -5,13 +5,13 @@
package noder package noder
import ( import (
"bytes"
"fmt" "fmt"
"internal/goversion" "internal/goversion"
"internal/pkgbits" "internal/pkgbits"
"io" "io"
"runtime" "runtime"
"sort" "sort"
"strings"
"cmd/compile/internal/base" "cmd/compile/internal/base"
"cmd/compile/internal/inline" "cmd/compile/internal/inline"
@ -180,7 +180,7 @@ func writePkgStub(noders []*noder) string {
w.Flush() w.Flush()
} }
var sb bytes.Buffer // TODO(mdempsky): strings.Builder after #44505 is resolved var sb strings.Builder
pw.DumpTo(&sb) pw.DumpTo(&sb)
// At this point, we're done with types2. Make sure the package is // At this point, we're done with types2. Make sure the package is

View File

@ -11,6 +11,7 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"go/constant" "go/constant"
"io"
"math/big" "math/big"
"os" "os"
"strings" "strings"
@ -148,9 +149,7 @@ func ReadImports(pkg *types.Pkg, data string) {
sLen := int64(ird.uint64()) sLen := int64(ird.uint64())
dLen := int64(ird.uint64()) dLen := int64(ird.uint64())
// TODO(mdempsky): Replace os.SEEK_CUR with io.SeekCurrent after whence, _ := ird.Seek(0, io.SeekCurrent)
// #44505 is fixed.
whence, _ := ird.Seek(0, os.SEEK_CUR)
stringData := data[whence : whence+sLen] stringData := data[whence : whence+sLen]
declData := data[whence+sLen : whence+sLen+dLen] declData := data[whence+sLen : whence+sLen+dLen]
ird.Seek(sLen+dLen, os.SEEK_CUR) ird.Seek(sLen+dLen, os.SEEK_CUR)

View File

@ -9,6 +9,7 @@ import (
"fmt" "fmt"
"go/constant" "go/constant"
"go/token" "go/token"
"io"
"math/big" "math/big"
"os" "os"
"runtime" "runtime"
@ -174,9 +175,7 @@ func (pr *PkgDecoder) NewDecoderRaw(k RelocKind, idx Index) Decoder {
Idx: idx, Idx: idx,
} }
// TODO(mdempsky) r.data.Reset(...) after #44505 is resolved. r.Data.Reset(pr.DataIdx(k, idx))
r.Data = *strings.NewReader(pr.DataIdx(k, idx))
r.Sync(SyncRelocs) r.Sync(SyncRelocs)
r.Relocs = make([]RelocEnt, r.Len()) r.Relocs = make([]RelocEnt, r.Len())
for i := range r.Relocs { for i := range r.Relocs {
@ -237,7 +236,7 @@ func (r *Decoder) Sync(mWant SyncMarker) {
return return
} }
pos, _ := r.Data.Seek(0, os.SEEK_CUR) // TODO(mdempsky): io.SeekCurrent after #44505 is resolved pos, _ := r.Data.Seek(0, io.SeekCurrent)
mHave := SyncMarker(r.rawUvarint()) mHave := SyncMarker(r.rawUvarint())
writerPCs := make([]int, r.rawUvarint()) writerPCs := make([]int, r.rawUvarint())
for i := range writerPCs { for i := range writerPCs {

View File

@ -12,6 +12,7 @@ import (
"io" "io"
"math/big" "math/big"
"runtime" "runtime"
"strings"
) )
// currentVersion is the current version number. // currentVersion is the current version number.
@ -161,7 +162,7 @@ type Encoder struct {
// Flush finalizes the element's bitstream and returns its Index. // Flush finalizes the element's bitstream and returns its Index.
func (w *Encoder) Flush() Index { func (w *Encoder) Flush() Index {
var sb bytes.Buffer // TODO(mdempsky): strings.Builder after #44505 is resolved var sb strings.Builder
// Backup the data so we write the relocations at the front. // Backup the data so we write the relocations at the front.
var tmp bytes.Buffer var tmp bytes.Buffer