11use std:: cmp;
22
33#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
4- pub struct BranchKey ( u128 ) ;
4+ pub struct BranchKey ( u64 ) ;
55
66impl BranchKey {
77 pub const fn root ( ) -> Self {
8- Self ( 0x80000000_00000000_00000000_00000000 )
8+ Self ( 0x80000000_00000000 )
99 }
1010
11- fn bits_branch ( self , branch_num : u128 , bits : u32 ) -> Result < Self , BranchNestingError > {
11+ fn bits_branch ( self , branch_num : u64 , bits : u32 ) -> Result < Self , BranchNestingError > {
1212 let trailing_zeros = self . 0 . trailing_zeros ( ) ;
1313 let allocated_shift = trailing_zeros. checked_sub ( bits) . ok_or ( BranchNestingError ( ( ) ) ) ?;
1414 Ok ( BranchKey (
@@ -18,7 +18,7 @@ impl BranchKey {
1818 ) )
1919 }
2020
21- pub fn branch ( self , branch_num : u128 , branch_space : u128 ) -> BranchKey {
21+ pub fn branch ( self , branch_num : u64 , branch_space : u64 ) -> BranchKey {
2222 debug_assert ! (
2323 branch_num < branch_space,
2424 "branch_num = {branch_num} should be less than branch_space = {branch_space}"
@@ -35,7 +35,7 @@ impl BranchKey {
3535 pub fn nest ( self , then : Self ) -> Result < Self , BranchNestingError > {
3636 let trailing_zeros = then. 0 . trailing_zeros ( ) ;
3737 let branch_num = then. 0 . wrapping_shr ( trailing_zeros + 1 ) ;
38- let bits = u128 :: BITS - trailing_zeros;
38+ let bits = u64 :: BITS - trailing_zeros;
3939 self . bits_branch ( branch_num, bits)
4040 }
4141}
0 commit comments