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 @@ -19,7 +19,10 @@ use js_sys::Date;
1919use leptos:: * ;
2020use leptos_meta:: * ;
2121use leptos_router:: * ;
22- use rand:: prelude:: * ;
22+ use rand_xoshiro:: {
23+ rand_core:: { RngCore , SeedableRng } ,
24+ Xoshiro256Plus ,
25+ } ;
2326use uiua:: { now, ConstantDef , Primitive , SysOp } ;
2427use uiua_editor:: {
2528 binding_name_class, lang,
@@ -261,9 +264,23 @@ pub fn MainPage() -> impl IntoView {
261264 let indices = if visits < 4 {
262265 vec ! [ 0 , rich_prims. len( ) - 3 , rich_prims. len( ) - 1 ]
263266 } else {
264- let mut rng = SmallRng :: seed_from_u64 ( visits as u64 ) ;
265267 let mut indices: Vec < usize > = ( 0 ..rich_prims. len ( ) ) . collect ( ) ;
266- indices. shuffle ( & mut rng) ;
268+ {
269+ // Shuffle indices
270+ let l = indices. len ( ) ;
271+ let upper = l. next_power_of_two ( ) ;
272+ let mut rng = Xoshiro256Plus :: seed_from_u64 ( visits as u64 ) ;
273+
274+ for i in 0 ..indices. len ( ) {
275+ let index = loop {
276+ let r = rng. next_u64 ( ) as usize % upper;
277+ if r < l {
278+ break r;
279+ }
280+ } ;
281+ indices. swap ( i, index) ;
282+ }
283+ }
267284 indices. truncate ( 3 ) ;
268285 indices. sort_unstable ( ) ;
269286 indices
You can’t perform that action at this time.
0 commit comments