File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ use js_sys::Date;
1818use leptos:: * ;
1919use leptos_meta:: * ;
2020use leptos_router:: * ;
21- use rand:: prelude:: * ;
21+ use rand_xoshiro:: {
22+ rand_core:: { RngCore , SeedableRng } ,
23+ Xoshiro256Plus ,
24+ } ;
2225use uiua:: { now, ConstantDef , Primitive , SysOp } ;
2326use uiua_editor:: {
2427 binding_name_class, lang,
@@ -253,9 +256,23 @@ pub fn MainPage() -> impl IntoView {
253256 let indices = if visits < 4 {
254257 vec ! [ 0 , rich_prims. len( ) - 3 , rich_prims. len( ) - 1 ]
255258 } else {
256- let mut rng = SmallRng :: seed_from_u64 ( visits as u64 ) ;
257259 let mut indices: Vec < usize > = ( 0 ..rich_prims. len ( ) ) . collect ( ) ;
258- indices. shuffle ( & mut rng) ;
260+ {
261+ // Shuffle indices
262+ let l = indices. len ( ) ;
263+ let upper = l. next_power_of_two ( ) ;
264+ let mut rng = Xoshiro256Plus :: seed_from_u64 ( visits as u64 ) ;
265+
266+ for i in 0 ..indices. len ( ) {
267+ let index = loop {
268+ let r = rng. next_u64 ( ) as usize % upper;
269+ if r < l {
270+ break r;
271+ }
272+ } ;
273+ indices. swap ( i, index) ;
274+ }
275+ }
259276 indices. truncate ( 3 ) ;
260277 indices. sort_unstable ( ) ;
261278 indices
You can’t perform that action at this time.
0 commit comments