Skip to content

Commit 55498de

Browse files
authored
Prefer strings.SplitSeq over strings.Split where possible (#7051)
SplitSeq returns an iterator over the substrings rather than constructing and returning a slice, which works well in cases where we are just iterating over the result anyways. Signed-off-by: Caleb Xu <caxu@redhat.com>
1 parent 15f34ea commit 55498de

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

internal/bindata/olm/manifests.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/olm/operator/install_mode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func (i *InstallMode) Set(str string) error {
3838
split := strings.SplitN(str, "=", 2)
3939
i.InstallModeType = v1alpha1.InstallModeType(split[0])
4040
if len(split) == 2 {
41-
namespaces := strings.Split(split[1], ",")
42-
for _, ns := range namespaces {
41+
namespaces := strings.SplitSeq(split[1], ",")
42+
for ns := range namespaces {
4343
i.TargetNamespaces = append(i.TargetNamespaces, strings.TrimSpace(ns))
4444
}
4545
sort.Strings(i.TargetNamespaces)

internal/util/projutil/interactive_promt_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func readArray(reader *bufio.Reader) []string {
106106
arr := make([]string, 0)
107107
text := readLine(reader)
108108

109-
for _, words := range strings.Split(text, ",") {
109+
for words := range strings.SplitSeq(text, ",") {
110110
arr = append(arr, strings.TrimSpace(words))
111111
}
112112
return arr

0 commit comments

Comments
 (0)