зеркало из https://github.com/golang/tools.git
txtar: use slices.Clone instead of copy
Use slices.Clone instead of copy now that x/tools uses Go >= 1.22.
Resolves an outstanding TODO.
Change-Id: Ia87f18e5e51f35dda5056538b9d0d0699c514ffc
GitHub-Last-Rev: 468e40586d
GitHub-Pull-Request: golang/tools#523
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613835
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Родитель
e603756b2b
Коммит
5cb6eeba24
|
@ -10,6 +10,7 @@ import (
|
|||
"io"
|
||||
"io/fs"
|
||||
"path"
|
||||
"slices"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -152,10 +153,7 @@ func (fsys *filesystem) ReadFile(name string) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
if file, ok := file.(*openFile); ok {
|
||||
// TODO: use slices.Clone once x/tools has 1.21 available.
|
||||
cp := make([]byte, file.size)
|
||||
copy(cp, file.data)
|
||||
return cp, err
|
||||
return slices.Clone(file.data), nil
|
||||
}
|
||||
return nil, &fs.PathError{Op: "read", Path: name, Err: fs.ErrInvalid}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче