mirror of https://github.com/golang/go.git
unicode/utf8: use builtin max function to simplify code
Change-Id: I6a73b645d074baaa4d09480bdf4192816a8c2450
GitHub-Last-Rev: 202d498eb0
GitHub-Pull-Request: golang/go#71945
Reviewed-on: https://go-review.googlesource.com/c/go/+/652177
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
c441eecbe9
commit
1e92ff11f5
|
|
@ -263,10 +263,7 @@ func DecodeLastRune(p []byte) (r rune, size int) {
|
|||
// guard against O(n^2) behavior when traversing
|
||||
// backwards through strings with long sequences of
|
||||
// invalid UTF-8.
|
||||
lim := end - UTFMax
|
||||
if lim < 0 {
|
||||
lim = 0
|
||||
}
|
||||
lim := max(end - UTFMax, 0)
|
||||
for start--; start >= lim; start-- {
|
||||
if RuneStart(p[start]) {
|
||||
break
|
||||
|
|
@ -303,10 +300,7 @@ func DecodeLastRuneInString(s string) (r rune, size int) {
|
|||
// guard against O(n^2) behavior when traversing
|
||||
// backwards through strings with long sequences of
|
||||
// invalid UTF-8.
|
||||
lim := end - UTFMax
|
||||
if lim < 0 {
|
||||
lim = 0
|
||||
}
|
||||
lim := max(end - UTFMax, 0)
|
||||
for start--; start >= lim; start-- {
|
||||
if RuneStart(s[start]) {
|
||||
break
|
||||
|
|
|
|||
Loading…
Reference in New Issue