forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removes offset > 0 branches from WeightedShuffle implementation
Changing offset definition to: let offset = (index - 1) & BIT_MASK will avoid all the if offset > 0 { /* ... */ } branches and massively simplifies the implementation. It also improves performance in the benchmarks: On master: test bench_weighted_shuffle_new ... bench: 34,313.20 ns/iter (+/- 382.82) test bench_weighted_shuffle_shuffle ... bench: 139,443.76 ns/iter (+/- 3,076.36) On the branch: test bench_weighted_shuffle_new ... bench: 30,306.27 ns/iter (+/- 475.48) test bench_weighted_shuffle_shuffle ... bench: 134,762.74 ns/iter (+/- 1,003.62)
- Loading branch information
1 parent
6612db0
commit e0c6f1c
Showing
1 changed file
with
21 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters