Skip to content

Commit

Permalink
docs: add code hint about future SIMD potential
Browse files Browse the repository at this point in the history
  • Loading branch information
mroth committed Oct 9, 2020
1 parent 29d84ac commit 12a8992
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions weightedrand.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func (chs Chooser) PickSource(rs *rand.Rand) interface{} {
// Thus, this is essentially manually inlined version. In our use case here, it
// results in a up to ~33% overall throughput increase for Pick().
func searchInts(a []int, x int) int {
// Possible further future optimization for searchInts via SIMD if we want
// to write some Go assembly code: http://0x80.pl/articles/simd-search.html
i, j := 0, len(a)
for i < j {
h := int(uint(i+j) >> 1) // avoid overflow when computing h
Expand Down

0 comments on commit 12a8992

Please sign in to comment.