aboutsummaryrefslogtreecommitdiff
path: root/proptools
diff options
context:
space:
mode:
Diffstat (limited to 'proptools')
-rw-r--r--proptools/escape.go7
-rw-r--r--proptools/escape_test.go3
-rw-r--r--proptools/extend.go3
3 files changed, 8 insertions, 5 deletions
diff --git a/proptools/escape.go b/proptools/escape.go
index 9792444..8fcf82e 100644
--- a/proptools/escape.go
+++ b/proptools/escape.go
@@ -15,6 +15,7 @@
package proptools
import (
+ "slices"
"strings"
"unsafe"
)
@@ -33,7 +34,7 @@ func NinjaEscapeList(slice []string) []string {
if !sliceCopied {
// If this was the first string that was modified by escaping then make a copy of the
// input slice to use as the output slice.
- slice = append([]string(nil), slice...)
+ slice = slices.Clone(slice)
sliceCopied = true
}
slice[i] = escaped
@@ -66,7 +67,7 @@ func ShellEscapeList(slice []string) []string {
if !sliceCopied {
// If this was the first string that was modified by escaping then make a copy of the
// input slice to use as the output slice.
- slice = append([]string(nil), slice...)
+ slice = slices.Clone(slice)
sliceCopied = true
}
slice[i] = escaped
@@ -83,7 +84,7 @@ func ShellEscapeListIncludingSpaces(slice []string) []string {
if !sliceCopied {
// If this was the first string that was modified by escaping then make a copy of the
// input slice to use as the output slice.
- slice = append([]string(nil), slice...)
+ slice = slices.Clone(slice)
sliceCopied = true
}
slice[i] = escaped
diff --git a/proptools/escape_test.go b/proptools/escape_test.go
index 2937058..91c9e76 100644
--- a/proptools/escape_test.go
+++ b/proptools/escape_test.go
@@ -18,6 +18,7 @@ import (
"bytes"
"os/exec"
"reflect"
+ "slices"
"testing"
"unsafe"
)
@@ -235,7 +236,7 @@ func TestNinjaEscapeList(t *testing.T) {
t.Run(tf.name, func(t *testing.T) {
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
- inCopy := append([]string(nil), tt.in...)
+ inCopy := slices.Clone(tt.in)
got := tf.f(tt.in)
diff --git a/proptools/extend.go b/proptools/extend.go
index eec5d43..af4e185 100644
--- a/proptools/extend.go
+++ b/proptools/extend.go
@@ -17,6 +17,7 @@ package proptools
import (
"fmt"
"reflect"
+ "slices"
"strings"
)
@@ -317,7 +318,7 @@ func extendPropertiesRecursive(dstValues []reflect.Value, srcValue reflect.Value
// of destinations to consider. Make a copy of dstValues if necessary
// to avoid modifying the backing array of an input parameter.
if !dstValuesCopied {
- dstValues = append([]reflect.Value(nil), dstValues...)
+ dstValues = slices.Clone(dstValues)
dstValuesCopied = true
}
dstValues = append(dstValues, embeddedDstValue)