Skip to content

Commit

Permalink
Remove unnecessary inlining hints
Browse files Browse the repository at this point in the history
  • Loading branch information
modelflat committed Jan 23, 2024
1 parent 0394330 commit 1ef1661
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
2 changes: 0 additions & 2 deletions hloo_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ pub fn make_permutations(item: TokenStream) -> TokenStream {
pub struct #struct_name;

impl #struct_name {
#[inline(always)]
pub fn get_variant(variant: usize) -> Box<dyn BitPermuter<#data_type_name, #mask_type_name>> {
match variant {
#( #variants_range => Box::new(#variants {}) as Box<dyn BitPermuter<#data_type_name, #mask_type_name>> ),*,
i => panic!("permutation variant out of range: {}", i),
}
}

#[inline(always)]
pub fn get_all_variants() -> Vec<Box<dyn BitPermuter<#data_type_name, #mask_type_name>>> {
vec![
#( Self::get_variant(#all_variants_range) ),*
Expand Down
4 changes: 1 addition & 3 deletions src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ where
fn remove(&mut self, keys: &[K]) -> Result<(), Self::Error>;

/// Retrieve candidates for a given search.
#[inline(never)]
fn get_candidates<'a>(&'a self, key: &K) -> Candidates<'a, K, V> {
let permuter = self.permuter();
let permuted_key = permuter.apply(key);
Expand Down Expand Up @@ -175,8 +174,7 @@ where
fn persist(&self) -> Result<(), Self::Error>;
}

/// Extract first element from a tuple.
#[inline(always)]
/// Extract the first element from a tuple.
pub fn extract_key<K: Copy, V>(item: &(K, V)) -> K {
item.0
}
Expand Down
1 change: 0 additions & 1 deletion src/lookup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ where
}

/// Perform a distance search.
#[inline(never)]
fn search(&self, key: &K, distance: u32) -> Result<SearchResult<V>, SearchError> {
let max_distance = self.max_search_distance();
if distance > max_distance {
Expand Down
11 changes: 4 additions & 7 deletions src/mmvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,13 @@ where

// On Windows it is required that file is not mapped before resizing.
// The safest option is to just drop and recreate the Data.
#[cfg(windows)]
{
if cfg!(windows) {
drop(self.data.take());
self.data = Some(Data::from_file_unchecked_resized(self.path(), new_len)?);
} else {
self.data.as_mut().map_or(Ok(()), |d| d.resize(new_len))?;
}

#[cfg(not(windows))]
self.data.as_mut().map_or(Ok(()), |d| d.resize(new_len))?;

Ok(())
}
}
Expand Down Expand Up @@ -419,8 +417,7 @@ fn resize_file_to_fit<T>(file: &File, header_size: u64, len: usize) -> io::Resul
unsafe fn mmap(file: &File, offset: u64, len: usize) -> io::Result<MmapMut> {
let mut opts = MmapOptions::new();
let mmap = opts.offset(offset).len(len).map_mut(file)?;
#[cfg(unix)]
{
if cfg!(unix) {
mmap.advise(memmap2::Advice::Random).ok();
}
Ok(mmap)
Expand Down

0 comments on commit 1ef1661

Please sign in to comment.