[go] all: replace strings.Split with strings.SplitSeq

53 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Sep 15, 2025, 8:34:50 PM9/15/25
to Gerrit Bot, 黄志文, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Knyszek, Emmanuel Odeke, Go LUCI, Keith Randall, Keith Randall, Alan Donovan, qiu laidongfeng, Brad Fitzpatrick, Ian Lance Taylor, Russ Cox, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
all: replace strings.Split with strings.SplitSeq

In Go 1.25+, strings.SplitSeq offers better
performance. Here are the benchmark results comparing
strings.Split and strings.SplitSeq in a for-loop, with the
benchmark code located in src/strings/iter_test.go:

goos: darwin
goarch: amd64
pkg: cmd/go/internal/auth
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
ParseGitAuth/standard-8 281.4n ± 1% 218.0n ± 11% -22.54% (p=0.000 n=10)
ParseGitAuth/with_url-8 549.1n ± 1% 480.5n ± 13% -12.48% (p=0.002 n=10)
ParseGitAuth/minimal-8 235.4n ± 1% 197.3n ± 7% -16.20% (p=0.000 n=10)
ParseGitAuth/complex-8 797.6n ± 2% 805.2n ± 4% ~ (p=0.481 n=10)
ParseGitAuth/empty-8 87.48n ± 3% 63.25n ± 6% -27.71% (p=0.000 n=10)
ParseGitAuth/malformed-8 228.8n ± 1% 171.2n ± 3% -25.17% (p=0.000 n=10)
geomean 288.9n 237.7n -17.72%

│ old.txt │ new.txt │
│ B/op │ B/op vs base │
ParseGitAuth/standard-8 192.00 ± 0% 96.00 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/with_url-8 400.0 ± 0% 288.0 ± 0% -28.00% (p=0.000 n=10)
ParseGitAuth/minimal-8 144.00 ± 0% 80.00 ± 0% -44.44% (p=0.000 n=10)
ParseGitAuth/complex-8 528.0 ± 0% 400.0 ± 0% -24.24% (p=0.000 n=10)
ParseGitAuth/empty-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/malformed-8 176.00 ± 0% 80.00 ± 0% -54.55% (p=0.000 n=10)
geomean 179.0 102.1 -42.96%

│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
ParseGitAuth/standard-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ParseGitAuth/with_url-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10)
ParseGitAuth/minimal-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ParseGitAuth/complex-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10)
ParseGitAuth/empty-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
ParseGitAuth/malformed-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
geomean 3.086 2.040 -33.91%

Updates #69315.
Change-Id: Id0219edea45d9658d527b863162ebe917e7821d9
GitHub-Last-Rev: 392b315e122f2c9ef8703ca2dbce8f82ec198556
GitHub-Pull-Request: golang/go#75259
Reviewed-by: Keith Randall <k...@golang.org>
Reviewed-by: Michael Knyszek <mkny...@google.com>
Reviewed-by: Emmanuel Odeke <emma...@orijtech.com>
Reviewed-by: Keith Randall <k...@google.com>
Auto-Submit: Emmanuel Odeke <emma...@orijtech.com>
Files:
  • M misc/ios/go_ios_exec.go
  • M src/cmd/cgo/gcc.go
  • M src/cmd/cgo/internal/test/testx.go
  • M src/cmd/compile/internal/base/flag.go
  • M src/cmd/dist/build.go
  • M src/cmd/distpack/pack.go
  • M src/cmd/fix/main.go
  • M src/cmd/go/internal/auth/gitauth.go
  • M src/cmd/go/internal/auth/gitauth_test.go
  • M src/cmd/go/internal/auth/netrc.go
  • M src/cmd/go/internal/doc/dirs.go
  • M src/cmd/go/internal/doc/pkg.go
  • M src/cmd/go/internal/list/list.go
  • M src/cmd/go/internal/modfetch/codehost/git.go
  • M src/cmd/go/internal/modfetch/codehost/vcs.go
  • M src/cmd/go/internal/modindex/build.go
  • M src/cmd/go/internal/modindex/scan.go
  • M src/cmd/go/internal/modload/buildlist.go
  • M src/cmd/go/internal/modload/init.go
  • M src/cmd/go/internal/modload/vendor.go
  • M src/cmd/go/internal/test/testflag.go
  • M src/cmd/go/internal/toolchain/path_windows.go
  • M src/cmd/go/internal/vcs/vcs.go
  • M src/cmd/go/internal/vcweb/vcweb.go
  • M src/cmd/go/internal/work/build.go
  • M src/cmd/go/internal/work/exec.go
  • M src/cmd/go/internal/work/gccgo.go
  • M src/cmd/internal/objabi/flag.go
  • M src/cmd/internal/script/cmds.go
  • M src/cmd/internal/script/scripttest/conditions.go
  • M src/go/ast/ast.go
  • M src/go/build/build.go
  • M src/go/build/constraint/expr.go
  • M src/internal/buildcfg/cfg.go
  • M src/internal/buildcfg/exp.go
  • M src/internal/testenv/testenv.go
  • M src/internal/trace/traceviewer/mmu.go
  • M src/os/exec/lp_windows.go
  • M src/strings/iter_test.go
Change size: M
Delta: 39 files changed, 178 insertions(+), 50 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Emmanuel Odeke, +1 by Keith Randall, +2 by Keith Randall, +1 by Michael Knyszek
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id0219edea45d9658d527b863162ebe917e7821d9
Gerrit-Change-Number: 701015
Gerrit-PatchSet: 8
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-Reviewer: qiu laidongfeng <26454...@qq.com>
Gerrit-CC: Alan Donovan <adon...@google.com>
Gerrit-CC: 黄志文 <alxp...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages