Skip to content

Commit d1ad4fc

Browse files
committed
Auto merge of #116 - rickvanprim:const_to_static, r=Amanieu
Group::static_empty() change const to static. Fixes #115.
2 parents 9b33a37 + e8b194b commit d1ad4fc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/raw/generic.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ impl Group {
5454
pub const WIDTH: usize = mem::size_of::<Self>();
5555

5656
/// Returns a full group of empty bytes, suitable for use as the initial
57-
/// value for an empty hash table.
57+
/// value for an empty hash table. This value is explicitly declared as
58+
/// a static variable to ensure the address is consistent across dylibs.
5859
///
5960
/// This is guaranteed to be aligned to the group size.
6061
#[inline]
@@ -63,7 +64,7 @@ impl Group {
6364
_align: Group,
6465
bytes: [u8; Group::WIDTH],
6566
};
66-
const ALIGNED_BYTES: AlignedBytes = AlignedBytes {
67+
static ALIGNED_BYTES: AlignedBytes = AlignedBytes {
6768
bytes: [EMPTY; Group::WIDTH],
6869
};
6970
unsafe { &ALIGNED_BYTES.bytes }

src/raw/sse2.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ pub const BITMASK_MASK: BitMaskWord = 0xffff;
1919
pub struct Group(x86::__m128i);
2020

2121
// FIXME: https://github.com/rust-lang/rust-clippy/issues/3859
22-
#[allow(clippy::use_self)]
22+
#[allow(clippy::use_self)]
2323
impl Group {
2424
/// Number of bytes in the group.
2525
pub const WIDTH: usize = mem::size_of::<Self>();
2626

2727
/// Returns a full group of empty bytes, suitable for use as the initial
28-
/// value for an empty hash table.
28+
/// value for an empty hash table. This value is explicitly declared as
29+
/// a static variable to ensure the address is consistent across dylibs.
2930
///
3031
/// This is guaranteed to be aligned to the group size.
3132
#[inline]
@@ -34,7 +35,7 @@ impl Group {
3435
_align: Group,
3536
bytes: [u8; Group::WIDTH],
3637
};
37-
const ALIGNED_BYTES: AlignedBytes = AlignedBytes {
38+
static ALIGNED_BYTES: AlignedBytes = AlignedBytes {
3839
bytes: [EMPTY; Group::WIDTH],
3940
};
4041
unsafe { &ALIGNED_BYTES.bytes }

0 commit comments

Comments
 (0)