The text was updated successfully, but these errors were encountered:
yangwenmai
changed the title
go/token: maybe we an improve compiler smarter about inlining sort.Search
go/token: maybe we can improve compiler smarter about inlining sort.Search
Dec 29, 2020
mdempsky
changed the title
go/token: maybe we can improve compiler smarter about inlining sort.Search
cmd/compile: better optimization/inlining for sort.Search
Dec 29, 2020
So sort.Search is a relatively simple function that takes a function argument and then calls it at exactly one call site. The compiler should be able to discount the cost of inlining when sort.Search is called with an inlinable function.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
go 1.15.6
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
When I use a helper func
SearchLineInfos()
andSearchFiles
similar assearchInts()
, I test those func benchmarkbenchmark result:
CL: https://go-review.googlesource.com/c/go/+/279447
What did you expect to see?
In
position.go
, we impl helper func for sort.Search.What did you see instead?
Remove
func searchInts(a []int, x int) int
cc @mdempsky
The text was updated successfully, but these errors were encountered: