mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-08-02 07:02:49 +02:00
Fix array size in insert/remove calls
makes the library easier to consume, also removes the need for the length check. also required to build https://github.com/erikh/isync Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
parent
bf297632fb
commit
7223de6fbb
1 changed files with 2 additions and 4 deletions
|
@ -151,16 +151,14 @@ impl<const BUCKETS: usize, const ITEM_BYTES: usize, const HASHES: usize> IBLT<BU
|
||||||
/// Insert a set item into this set.
|
/// Insert a set item into this set.
|
||||||
/// This will panic if the slice is smaller than ITEM_BYTES.
|
/// This will panic if the slice is smaller than ITEM_BYTES.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn insert(&mut self, key: &[u8]) {
|
pub fn insert(&mut self, key: &[u8; ITEM_BYTES]) {
|
||||||
assert!(key.len() >= ITEM_BYTES);
|
|
||||||
self.ins_rem(unsafe { &*key.as_ptr().cast() }, 1);
|
self.ins_rem(unsafe { &*key.as_ptr().cast() }, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert a set item into this set.
|
/// Insert a set item into this set.
|
||||||
/// This will panic if the slice is smaller than ITEM_BYTES.
|
/// This will panic if the slice is smaller than ITEM_BYTES.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn remove(&mut self, key: &[u8]) {
|
pub fn remove(&mut self, key: &[u8; ITEM_BYTES]) {
|
||||||
assert!(key.len() >= ITEM_BYTES);
|
|
||||||
self.ins_rem(unsafe { &*key.as_ptr().cast() }, -1);
|
self.ins_rem(unsafe { &*key.as_ptr().cast() }, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue