diff options
author | subham sarkar <sarkar.subhams2@gmail.com> | 2021-07-20 17:17:14 +0000 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-08-24 15:52:22 +0000 |
commit | f98b6111eb8edda63a785db5678418b9eecbc5e9 (patch) | |
tree | 51fecb2dd49abfd43aad563d58aa7faa98bd0a51 /src | |
parent | 8eeb1bff1d7107828b41af08e599c78fc36bab30 (diff) | |
download | go-f98b6111eb8edda63a785db5678418b9eecbc5e9.tar.gz go-f98b6111eb8edda63a785db5678418b9eecbc5e9.zip |
go/token: match the implementation of index selection with sort.Search
name old time/op new time/op delta
SearchInts-8 15.5ns ± 2% 13.7ns ± 4% -11.87% (p=0.008 n=5+5)
(see CL 36332 for the original change to sort.Search)
Change-Id: If452818185b92b8b3548b066f475e493d604ea29
GitHub-Last-Rev: 32dd3cffa6b54b332948ac6a2929458defd4838f
GitHub-Pull-Request: golang/go#47293
Reviewed-on: https://go-review.googlesource.com/c/go/+/335809
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/go/token/position.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/go/token/position.go b/src/go/token/position.go index 0d7982c670..ce4af03923 100644 --- a/src/go/token/position.go +++ b/src/go/token/position.go @@ -540,7 +540,7 @@ func searchInts(a []int, x int) int { // TODO(gri): Remove this when compilers have caught up. i, j := 0, len(a) for i < j { - h := i + (j-i)>>1 // avoid overflow when computing h + h := int(uint(i+j) >> 1) // avoid overflow when computing h // i ≤ h < j if a[h] <= x { i = h + 1 |