mirror of
https://github.com/golang/go.git
synced 2026-06-27 19:30:52 +00:00
bytes, strings: use builtin min function in genSplit
Replace if n > len(s)+1 { n = len(s)+1 } pattern with the more
concise min(n, len(s)+1) built-in function.
This reduces 3 lines of code and improves readability.
Change-Id: I20a17139e98548ef0e01aa00b13b0fb5927bcfd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/778740
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
03d1f8efc8
commit
64315a2d18
2 changed files with 2 additions and 6 deletions
|
|
@ -380,9 +380,7 @@ func genSplit(s, sep []byte, sepSave, n int) [][]byte {
|
|||
if n < 0 {
|
||||
n = Count(s, sep) + 1
|
||||
}
|
||||
if n > len(s)+1 {
|
||||
n = len(s) + 1
|
||||
}
|
||||
n = min(n, len(s)+1)
|
||||
|
||||
a := make([][]byte, n)
|
||||
n--
|
||||
|
|
|
|||
|
|
@ -282,9 +282,7 @@ func genSplit(s, sep string, sepSave, n int) []string {
|
|||
n = Count(s, sep) + 1
|
||||
}
|
||||
|
||||
if n > len(s)+1 {
|
||||
n = len(s) + 1
|
||||
}
|
||||
n = min(n, len(s)+1)
|
||||
a := make([]string, n)
|
||||
n--
|
||||
i := 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue