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/time | |
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/time')
-rw-r--r-- | src/time/zoneinfo.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/time/zoneinfo.go b/src/time/zoneinfo.go index 4edcf3d98f..42d40d584e 100644 --- a/src/time/zoneinfo.go +++ b/src/time/zoneinfo.go @@ -184,7 +184,7 @@ func (l *Location) lookup(sec int64) (name string, offset int, start, end int64, lo := 0 hi := len(tx) for hi-lo > 1 { - m := lo + (hi-lo)/2 + m := int(uint(lo+hi) >> 1) lim := tx[m].when if sec < lim { end = lim |