@@ -10,10 +10,6 @@ pub type FeistelPrecomputed = (u32, u32, u32);
1010// Find the minimum number of even bits to represent `num_elements`
1111// within a `u32` maximum. Returns the left and right masks evenly
1212// distributed that together add up to that minimum number of bits.
13- // TODO: Optimization: Evaluate dropping the `right_mask` inside
14- // all of the internal computations, just apply it at the end to
15- // get the output into the desired range (the internal hash won't
16- // care if we use less than 32 bits, it will take the same time).
1713pub fn precompute ( num_elements : u32 ) -> FeistelPrecomputed {
1814 let mut next_pow4 = 4 ;
1915 let mut log4 = 1 ;
@@ -47,9 +43,6 @@ pub fn permute(
4743 // Since we are representing `num_elements` using an even number of bits,
4844 // that can encode many values above it, so keep repeating the operation
4945 // until we land in the permitted range.
50- // TODO: Optimization: Do not repeat the entire `encode`, just one round
51- // at a time (following the `keys` order) until where in the `num_elements`
52- // range.
5346
5447 u
5548}
@@ -120,15 +113,13 @@ fn feistel(right: u32, key: u32, right_mask: u32) -> u32 {
120113 data[ 5 ] = ( key >> 16 ) as u8 ;
121114 data[ 6 ] = ( key >> 8 ) as u8 ;
122115 data[ 7 ] = key as u8 ;
123- // TODO: Optimization: use `load` as `u64`.
124116
125117 let hash = Blake2s :: digest ( & data) ;
126118
127119 let r = u32:: from ( hash[ 0 ] ) << 24
128120 | u32:: from ( hash[ 1 ] ) << 16
129121 | u32:: from ( hash[ 2 ] ) << 8
130122 | u32:: from ( hash[ 3 ] ) ;
131- // TODO: Optimization: same with `u32`.
132123
133124 r & right_mask
134125}
0 commit comments