Skip to content

Commit 584aad5

Browse files
qiulaidongfenggopherbot
authored andcommitted
go/doc/comment: use slices.BinarySearch
Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e GitHub-Last-Rev: dba95de GitHub-Pull-Request: #62610 Reviewed-on: https://go-review.googlesource.com/c/go/+/527956 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent e5600f0 commit 584aad5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/go/doc/comment/parse.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package comment
66

77
import (
8-
"sort"
8+
"slices"
99
"strings"
1010
"unicode"
1111
"unicode/utf8"
@@ -260,9 +260,8 @@ func (d *parseDoc) lookupPkg(pkg string) (importPath string, ok bool) {
260260
}
261261

262262
func isStdPkg(path string) bool {
263-
// TODO: Use slices.BinarySearch when possible.
264-
i := sort.Search(len(stdPkgs), func(i int) bool { return stdPkgs[i] >= path })
265-
return i < len(stdPkgs) && stdPkgs[i] == path
263+
_, ok := slices.BinarySearch(stdPkgs, path)
264+
return ok
266265
}
267266

268267
// DefaultLookupPackage is the default package lookup

0 commit comments

Comments
 (0)