@@ -20,11 +20,11 @@ type GroupWord = u64;
20
20
) ) ]
21
21
type GroupWord = u32 ;
22
22
23
- pub type BitMaskWord = GroupWord ;
24
- pub const BITMASK_STRIDE : usize = 8 ;
23
+ pub ( crate ) type BitMaskWord = GroupWord ;
24
+ pub ( crate ) const BITMASK_STRIDE : usize = 8 ;
25
25
// We only care about the highest bit of each byte for the mask.
26
26
#[ allow( clippy:: cast_possible_truncation, clippy:: unnecessary_cast) ]
27
- pub const BITMASK_MASK : BitMaskWord = 0x8080_8080_8080_8080_u64 as GroupWord ;
27
+ pub ( crate ) const BITMASK_MASK : BitMaskWord = 0x8080_8080_8080_8080_u64 as GroupWord ;
28
28
29
29
/// Helper function to replicate a byte across a `GroupWord`.
30
30
#[ inline]
@@ -37,7 +37,7 @@ fn repeat(byte: u8) -> GroupWord {
37
37
///
38
38
/// This implementation uses a word-sized integer.
39
39
#[ derive( Copy , Clone ) ]
40
- pub struct Group ( GroupWord ) ;
40
+ pub ( crate ) struct Group ( GroupWord ) ;
41
41
42
42
// We perform all operations in the native endianness, and convert to
43
43
// little-endian just before creating a BitMask. The can potentially
@@ -46,14 +46,14 @@ pub struct Group(GroupWord);
46
46
#[ allow( clippy:: use_self) ]
47
47
impl Group {
48
48
/// Number of bytes in the group.
49
- pub const WIDTH : usize = mem:: size_of :: < Self > ( ) ;
49
+ pub ( crate ) const WIDTH : usize = mem:: size_of :: < Self > ( ) ;
50
50
51
51
/// Returns a full group of empty bytes, suitable for use as the initial
52
52
/// value for an empty hash table.
53
53
///
54
54
/// This is guaranteed to be aligned to the group size.
55
55
#[ inline]
56
- pub const fn static_empty ( ) -> & ' static [ u8 ; Group :: WIDTH ] {
56
+ pub ( crate ) const fn static_empty ( ) -> & ' static [ u8 ; Group :: WIDTH ] {
57
57
#[ repr( C ) ]
58
58
struct AlignedBytes {
59
59
_align : [ Group ; 0 ] ,
@@ -69,15 +69,15 @@ impl Group {
69
69
/// Loads a group of bytes starting at the given address.
70
70
#[ inline]
71
71
#[ allow( clippy:: cast_ptr_alignment) ] // unaligned load
72
- pub unsafe fn load ( ptr : * const u8 ) -> Self {
72
+ pub ( crate ) unsafe fn load ( ptr : * const u8 ) -> Self {
73
73
Group ( ptr:: read_unaligned ( ptr. cast ( ) ) )
74
74
}
75
75
76
76
/// Loads a group of bytes starting at the given address, which must be
77
77
/// aligned to `mem::align_of::<Group>()`.
78
78
#[ inline]
79
79
#[ allow( clippy:: cast_ptr_alignment) ]
80
- pub unsafe fn load_aligned ( ptr : * const u8 ) -> Self {
80
+ pub ( crate ) unsafe fn load_aligned ( ptr : * const u8 ) -> Self {
81
81
// FIXME: use align_offset once it stabilizes
82
82
debug_assert_eq ! ( ptr as usize & ( mem:: align_of:: <Self >( ) - 1 ) , 0 ) ;
83
83
Group ( ptr:: read ( ptr. cast ( ) ) )
@@ -87,7 +87,7 @@ impl Group {
87
87
/// aligned to `mem::align_of::<Group>()`.
88
88
#[ inline]
89
89
#[ allow( clippy:: cast_ptr_alignment) ]
90
- pub unsafe fn store_aligned ( self , ptr : * mut u8 ) {
90
+ pub ( crate ) unsafe fn store_aligned ( self , ptr : * mut u8 ) {
91
91
// FIXME: use align_offset once it stabilizes
92
92
debug_assert_eq ! ( ptr as usize & ( mem:: align_of:: <Self >( ) - 1 ) , 0 ) ;
93
93
ptr:: write ( ptr. cast ( ) , self . 0 ) ;
@@ -104,7 +104,7 @@ impl Group {
104
104
/// - This only happens if there is at least 1 true match.
105
105
/// - The chance of this happening is very low (< 1% chance per byte).
106
106
#[ inline]
107
- pub fn match_byte ( self , byte : u8 ) -> BitMask {
107
+ pub ( crate ) fn match_byte ( self , byte : u8 ) -> BitMask {
108
108
// This algorithm is derived from
109
109
// https://graphics.stanford.edu/~seander/bithacks.html##ValueInWord
110
110
let cmp = self . 0 ^ repeat ( byte) ;
@@ -114,7 +114,7 @@ impl Group {
114
114
/// Returns a `BitMask` indicating all bytes in the group which are
115
115
/// `EMPTY`.
116
116
#[ inline]
117
- pub fn match_empty ( self ) -> BitMask {
117
+ pub ( crate ) fn match_empty ( self ) -> BitMask {
118
118
// If the high bit is set, then the byte must be either:
119
119
// 1111_1111 (EMPTY) or 1000_0000 (DELETED).
120
120
// So we can just check if the top two bits are 1 by ANDing them.
@@ -124,14 +124,14 @@ impl Group {
124
124
/// Returns a `BitMask` indicating all bytes in the group which are
125
125
/// `EMPTY` or `DELETED`.
126
126
#[ inline]
127
- pub fn match_empty_or_deleted ( self ) -> BitMask {
127
+ pub ( crate ) fn match_empty_or_deleted ( self ) -> BitMask {
128
128
// A byte is EMPTY or DELETED iff the high bit is set
129
129
BitMask ( ( self . 0 & repeat ( 0x80 ) ) . to_le ( ) )
130
130
}
131
131
132
132
/// Returns a `BitMask` indicating all bytes in the group which are full.
133
133
#[ inline]
134
- pub fn match_full ( self ) -> BitMask {
134
+ pub ( crate ) fn match_full ( self ) -> BitMask {
135
135
self . match_empty_or_deleted ( ) . invert ( )
136
136
}
137
137
@@ -140,7 +140,7 @@ impl Group {
140
140
/// - `DELETED => EMPTY`
141
141
/// - `FULL => DELETED`
142
142
#[ inline]
143
- pub fn convert_special_to_empty_and_full_to_deleted ( self ) -> Self {
143
+ pub ( crate ) fn convert_special_to_empty_and_full_to_deleted ( self ) -> Self {
144
144
// Map high_bit = 1 (EMPTY or DELETED) to 1111_1111
145
145
// and high_bit = 0 (FULL) to 1000_0000
146
146
//
0 commit comments