#![allow(unsafe_code)]
#![allow(
clippy::inline_always,
reason = "these feature-gated leaf lookups are benchmarked hot-path APIs"
)]
use super::BitMatrix;
use crate::NodeIndex;
impl BitMatrix {
#[must_use]
#[inline(always)]
pub fn contains_fast(&self, source: NodeIndex, target: NodeIndex) -> bool {
let count = self.node_count();
if source.index() >= count || target.index() >= count {
return false;
}
unsafe { self.contains_unchecked(source, target) }
}
#[must_use]
#[inline(always)]
pub unsafe fn contains_unchecked(&self, source: NodeIndex, target: NodeIndex) -> bool {
debug_assert!(source.index() < self.node_count());
debug_assert!(target.index() < self.node_count());
let slot = source.index() * self.node_count() + target.index();
let word = unsafe { self.words.get_unchecked(slot / 64) };
word & (1_u64 << (slot % 64)) != 0
}
}