diff options
author | Jes Cok <xigua67damn@gmail.com> | 2023-09-07 11:07:30 +0000 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-09-09 01:46:03 +0000 |
commit | 267323ef2d22da4b2a5ed1ed6f220421aa580a6c (patch) | |
tree | c3f00aaf1e254d4585a5dc8ebf09daad9d019654 /src/regexp | |
parent | 4651c0c6d9239514715123f0788d4c2c769130f7 (diff) | |
download | go-267323ef2d22da4b2a5ed1ed6f220421aa580a6c.tar.gz go-267323ef2d22da4b2a5ed1ed6f220421aa580a6c.zip |
all: calculate the median uniformly
Like sort.Search, use "h := int(uint(i+j) >> 1)" style code to calculate
the median.
Change-Id: Ifb1a19dde1c6ed6c1654bc642fc9565a8b6c5fc4
GitHub-Last-Rev: e2213b738832f1674948d6507f40e2c0b98cb972
GitHub-Pull-Request: golang/go#62503
Reviewed-on: https://go-review.googlesource.com/c/go/+/526496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/regexp')
-rw-r--r-- | src/regexp/syntax/prog.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/regexp/syntax/prog.go b/src/regexp/syntax/prog.go index 66995e2052..d69ae1a12d 100644 --- a/src/regexp/syntax/prog.go +++ b/src/regexp/syntax/prog.go @@ -247,7 +247,7 @@ func (i *Inst) MatchRunePos(r rune) int { lo := 0 hi := len(rune) / 2 for lo < hi { - m := lo + (hi-lo)/2 + m := int(uint(lo+hi) >> 1) if c := rune[2*m]; c <= r { if r <= rune[2*m+1] { return m |