14
14
const MULTIPLIER : u128 = 0x2360_ED05_1FC6_5DA4_4385_DF64_9FCC_F645 ;
15
15
16
16
use core:: fmt;
17
- use rand_core:: { le, Error , RngCore , SeedableRng } ;
17
+ use rand_core:: { impls , le, Error , RngCore , SeedableRng } ;
18
18
#[ cfg( feature = "serde1" ) ] use serde:: { Deserialize , Serialize } ;
19
19
20
20
/// A PCG random number generator (XSL RR 128/64 (LCG) variant).
@@ -146,7 +146,7 @@ impl RngCore for Lcg128Xsl64 {
146
146
147
147
#[ inline]
148
148
fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
149
- fill_bytes_impl ( self , dest)
149
+ impls :: fill_bytes_via_next ( self , dest)
150
150
}
151
151
152
152
#[ inline]
@@ -237,8 +237,7 @@ impl SeedableRng for Mcg128Xsl64 {
237
237
// Read as if a little-endian u128 value:
238
238
let mut seed_u64 = [ 0u64 ; 2 ] ;
239
239
le:: read_u64_into ( & seed, & mut seed_u64) ;
240
- let state = u128:: from ( seed_u64[ 0 ] ) |
241
- u128:: from ( seed_u64[ 1 ] ) << 64 ;
240
+ let state = u128:: from ( seed_u64[ 0 ] ) | u128:: from ( seed_u64[ 1 ] ) << 64 ;
242
241
Mcg128Xsl64 :: new ( state)
243
242
}
244
243
}
@@ -257,7 +256,7 @@ impl RngCore for Mcg128Xsl64 {
257
256
258
257
#[ inline]
259
258
fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
260
- fill_bytes_impl ( self , dest)
259
+ impls :: fill_bytes_via_next ( self , dest)
261
260
}
262
261
263
262
#[ inline]
@@ -278,19 +277,3 @@ fn output_xsl_rr(state: u128) -> u64 {
278
277
let xsl = ( ( state >> XSHIFT ) as u64 ) ^ ( state as u64 ) ;
279
278
xsl. rotate_right ( rot)
280
279
}
281
-
282
- #[ inline( always) ]
283
- fn fill_bytes_impl < R : RngCore + ?Sized > ( rng : & mut R , dest : & mut [ u8 ] ) {
284
- let mut left = dest;
285
- while left. len ( ) >= 8 {
286
- let ( l, r) = { left } . split_at_mut ( 8 ) ;
287
- left = r;
288
- let chunk: [ u8 ; 8 ] = rng. next_u64 ( ) . to_le_bytes ( ) ;
289
- l. copy_from_slice ( & chunk) ;
290
- }
291
- let n = left. len ( ) ;
292
- if n > 0 {
293
- let chunk: [ u8 ; 8 ] = rng. next_u64 ( ) . to_le_bytes ( ) ;
294
- left. copy_from_slice ( & chunk[ ..n] ) ;
295
- }
296
- }
0 commit comments