]> Cypherpunks repositories - gostls13.git/commitdiff
all: use slices.Delete
authorTobias Klauser <tklauser@distanz.ch>
Tue, 1 Oct 2024 09:33:50 +0000 (11:33 +0200)
committerGopher Robot <gobot@golang.org>
Tue, 1 Oct 2024 14:55:00 +0000 (14:55 +0000)
Change-Id: Ifb6aa07b32127907cdc2df44b2dbddd6296775c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/616737
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/cmd/cgo/internal/testerrors/ptr_test.go
src/cmd/compile/internal/ssa/debug.go
src/cmd/compile/internal/ssa/poset.go
src/cmd/fix/netipv6zone.go
src/cmd/go/go_test.go
src/go/token/position.go

index 8fff7615d3560c78e0d8ec7ed7c75ccb6f68c6b8..4f8a0ee583a7873d77b61b2036b78a96e55050c9 100644 (file)
@@ -607,7 +607,7 @@ func buildPtrTests(t *testing.T, gopath string, cgocheck2 bool) (exe string) {
                goexperiment = append(goexperiment, "cgocheck2")
                changed = true
        } else if !cgocheck2 && i >= 0 {
-               goexperiment = append(goexperiment[:i], goexperiment[i+1:]...)
+               goexperiment = slices.Delete(goexperiment, i, i+1)
                changed = true
        }
        if changed {
index 91620798ff599f12bd1cf687cf3a18ccf40076e0..381777c17da03b5d5c1531296e7ea427d53479e1 100644 (file)
@@ -1681,7 +1681,7 @@ func locatePrologEnd(f *Func, needCloCtx bool) (ID, *Value) {
        removeReg := func(r ID) bool {
                for i := 0; i < len(regArgs); i++ {
                        if regArgs[i] == r {
-                               regArgs = append(regArgs[:i], regArgs[i+1:]...)
+                               regArgs = slices.Delete(regArgs, i, i+1)
                                return true
                        }
                }
index 50b4d1788929170dd9f3cc5eefc8d1ef18901640..b7859166f48a98bdb3532fd062836bde79ae16b0 100644 (file)
@@ -7,6 +7,7 @@ package ssa
 import (
        "fmt"
        "os"
+       "slices"
 )
 
 // If true, check poset integrity after every mutation
@@ -350,7 +351,7 @@ func (po *poset) changeroot(oldr, newr uint32) {
 func (po *poset) removeroot(r uint32) {
        for i := range po.roots {
                if po.roots[i] == r {
-                       po.roots = append(po.roots[:i], po.roots[i+1:]...)
+                       po.roots = slices.Delete(po.roots, i, i+1)
                        return
                }
        }
index 199fcf5bf5976520857e7c194341e5443f60684a..c27b4b4529abfb9801a11b1ebbb47600e9ba3d66 100644 (file)
@@ -4,7 +4,10 @@
 
 package main
 
-import "go/ast"
+import (
+       "go/ast"
+       "slices"
+)
 
 func init() {
        register(netipv6zoneFix)
@@ -52,7 +55,7 @@ func netipv6zone(f *ast.File) bool {
                                        }
                                case 1:
                                        if elit, ok := e.(*ast.BasicLit); ok && elit.Value == "0" {
-                                               cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
+                                               cl.Elts = slices.Delete(cl.Elts, i, i+1)
                                        } else {
                                                cl.Elts[i] = &ast.KeyValueExpr{
                                                        Key:   ast.NewIdent("Port"),
index 3370331b854245d1a8053ec5f712fe3ec7181a81..b99656d3ce9665249e768be542aa2c4eb8502553 100644 (file)
@@ -25,6 +25,7 @@ import (
        "path/filepath"
        "regexp"
        "runtime"
+       "slices"
        "strconv"
        "strings"
        "testing"
@@ -473,7 +474,7 @@ func (tg *testgoData) unsetenv(name string) {
        }
        for i, v := range tg.env {
                if strings.HasPrefix(v, name+"=") {
-                       tg.env = append(tg.env[:i], tg.env[i+1:]...)
+                       tg.env = slices.Delete(tg.env, i, i+1)
                        break
                }
        }
index 4675e93703a2040ba030ee2c6d021fcd47dfcefa..35ef14da8773da230f7584bb880663a4a94e0ef9 100644 (file)
@@ -503,7 +503,7 @@ func (s *FileSet) RemoveFile(file *File) {
 
        if i := searchFiles(s.files, file.base); i >= 0 && s.files[i] == file {
                last := &s.files[len(s.files)-1]
-               s.files = append(s.files[:i], s.files[i+1:]...)
+               s.files = slices.Delete(s.files, i, i+1)
                *last = nil // don't prolong lifetime when popping last element
        }
 }