From 18bfe131fe360d73d2b48157f4b9180846b763ee Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Fri, 23 Apr 2021 10:47:13 +0900 Subject: [PATCH] Removed all inline(always) like a baboon. --- src/collector/top_collector.rs | 4 ++-- src/common/bitset.rs | 12 ++++++------ src/common/mod.rs | 8 ++++---- src/directory/owned_bytes.rs | 8 ++++---- src/fastfield/delete.rs | 2 +- src/fieldnorm/code.rs | 4 ++-- src/fieldnorm/reader.rs | 6 +++--- src/postings/block_segment_postings.rs | 4 ++-- src/postings/compression/vint.rs | 8 ++++---- src/postings/segment_postings.rs | 2 +- src/postings/skip.rs | 10 +++++----- src/postings/stacker/expull.rs | 2 +- src/postings/stacker/memory_arena.rs | 4 ++-- src/postings/stacker/term_hashmap.rs | 4 ++-- src/query/bm25.rs | 4 ++-- src/query/exclude.rs | 2 +- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/collector/top_collector.rs b/src/collector/top_collector.rs index c28c27e22..6ed44db7b 100644 --- a/src/collector/top_collector.rs +++ b/src/collector/top_collector.rs @@ -180,7 +180,7 @@ impl TopSegmentCollector { /// Return true iff at least K documents have gone through /// the collector. - #[inline(always)] + #[inline] pub(crate) fn at_capacity(&self) -> bool { self.heap.len() >= self.limit } @@ -189,7 +189,7 @@ impl TopSegmentCollector { /// /// It collects documents until it has reached the max capacity. Once it reaches capacity, it /// will compare the lowest scoring item with the given one and keep whichever is greater. - #[inline(always)] + #[inline] pub fn collect(&mut self, doc: DocId, feature: T) { if self.at_capacity() { // It's ok to unwrap as long as a limit of 0 is forbidden. diff --git a/src/common/bitset.rs b/src/common/bitset.rs index 0a8d6f4de..0eb4d8da6 100644 --- a/src/common/bitset.rs +++ b/src/common/bitset.rs @@ -59,19 +59,19 @@ impl TinySet { /// Creates a new `TinySet` containing only one element /// within `[0; 64[` - #[inline(always)] + #[inline] pub fn singleton(el: u32) -> TinySet { TinySet(1u64 << u64::from(el)) } /// Insert a new element within [0..64[ - #[inline(always)] + #[inline] pub fn insert(self, el: u32) -> TinySet { self.union(TinySet::singleton(el)) } /// Insert a new element within [0..64[ - #[inline(always)] + #[inline] pub fn insert_mut(&mut self, el: u32) -> bool { let old = *self; *self = old.insert(el); @@ -79,20 +79,20 @@ impl TinySet { } /// Returns the union of two tinysets - #[inline(always)] + #[inline] pub fn union(self, other: TinySet) -> TinySet { TinySet(self.0 | other.0) } /// Returns true iff the `TinySet` is empty. - #[inline(always)] + #[inline] pub fn is_empty(self) -> bool { self.0 == 0u64 } /// Returns the lowest element in the `TinySet` /// and removes it. - #[inline(always)] + #[inline] pub fn pop_lowest(&mut self) -> Option { if self.is_empty() { None diff --git a/src/common/mod.rs b/src/common/mod.rs index 45bee6a59..9405067ba 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -99,13 +99,13 @@ const HIGHEST_BIT: u64 = 1 << 63; /// /// # See also /// The [reverse mapping is `u64_to_i64`](./fn.u64_to_i64.html). -#[inline(always)] +#[inline] pub fn i64_to_u64(val: i64) -> u64 { (val as u64) ^ HIGHEST_BIT } /// Reverse the mapping given by [`i64_to_u64`](./fn.i64_to_u64.html). -#[inline(always)] +#[inline] pub fn u64_to_i64(val: u64) -> i64 { (val ^ HIGHEST_BIT) as i64 } @@ -127,7 +127,7 @@ pub fn u64_to_i64(val: u64) -> i64 { /// /// # See also /// The [reverse mapping is `u64_to_f64`](./fn.u64_to_f64.html). -#[inline(always)] +#[inline] pub fn f64_to_u64(val: f64) -> u64 { let bits = val.to_bits(); if val.is_sign_positive() { @@ -138,7 +138,7 @@ pub fn f64_to_u64(val: f64) -> u64 { } /// Reverse the mapping given by [`i64_to_u64`](./fn.i64_to_u64.html). -#[inline(always)] +#[inline] pub fn u64_to_f64(val: u64) -> f64 { f64::from_bits(if val & HIGHEST_BIT != 0 { val ^ HIGHEST_BIT diff --git a/src/directory/owned_bytes.rs b/src/directory/owned_bytes.rs index 33d2487a5..dbe760e88 100644 --- a/src/directory/owned_bytes.rs +++ b/src/directory/owned_bytes.rs @@ -51,13 +51,13 @@ impl OwnedBytes { /// Returns the underlying slice of data. /// `Deref` and `AsRef` are also available. - #[inline(always)] + #[inline] pub fn as_slice(&self) -> &[u8] { self.data } /// Returns the len of the slice. - #[inline(always)] + #[inline] pub fn len(&self) -> usize { self.data.len() } @@ -84,7 +84,7 @@ impl OwnedBytes { } /// Returns true iff this `OwnedBytes` is empty. - #[inline(always)] + #[inline] pub fn is_empty(&self) -> bool { self.as_slice().is_empty() } @@ -92,7 +92,7 @@ impl OwnedBytes { /// Drops the left most `advance_len` bytes. /// /// See also [.clip(clip_len: usize))](#method.clip). - #[inline(always)] + #[inline] pub fn advance(&mut self, advance_len: usize) { self.data = &self.data[advance_len..] } diff --git a/src/fastfield/delete.rs b/src/fastfield/delete.rs index 58d9b77b3..28c1b35fb 100644 --- a/src/fastfield/delete.rs +++ b/src/fastfield/delete.rs @@ -83,7 +83,7 @@ impl DeleteBitSet { } /// Returns true iff the document has been marked as deleted. - #[inline(always)] + #[inline] pub fn is_deleted(&self, doc: DocId) -> bool { let byte_offset = doc / 8u32; let b: u8 = self.data.as_slice()[byte_offset as usize]; diff --git a/src/fieldnorm/code.rs b/src/fieldnorm/code.rs index 4c4e78e73..c6846932b 100644 --- a/src/fieldnorm/code.rs +++ b/src/fieldnorm/code.rs @@ -1,9 +1,9 @@ -#[inline(always)] +#[inline] pub fn id_to_fieldnorm(id: u8) -> u32 { FIELD_NORMS_TABLE[id as usize] } -#[inline(always)] +#[inline] pub fn fieldnorm_to_id(fieldnorm: u32) -> u8 { FIELD_NORMS_TABLE .binary_search(&fieldnorm) diff --git a/src/fieldnorm/reader.rs b/src/fieldnorm/reader.rs index e1ce15007..837e55336 100644 --- a/src/fieldnorm/reader.rs +++ b/src/fieldnorm/reader.rs @@ -133,7 +133,7 @@ impl FieldNormReader { } /// Returns the `fieldnorm_id` associated to a document. - #[inline(always)] + #[inline] pub fn fieldnorm_id(&self, doc_id: DocId) -> u8 { match &self.0 { ReaderImplEnum::FromData(data) => { @@ -145,14 +145,14 @@ impl FieldNormReader { } /// Converts a `fieldnorm_id` into a fieldnorm. - #[inline(always)] + #[inline] pub fn id_to_fieldnorm(id: u8) -> u32 { id_to_fieldnorm(id) } /// Converts a `fieldnorm` into a `fieldnorm_id`. /// (This function is not injective). - #[inline(always)] + #[inline] pub fn fieldnorm_to_id(fieldnorm: u32) -> u8 { fieldnorm_to_id(fieldnorm) } diff --git a/src/postings/block_segment_postings.rs b/src/postings/block_segment_postings.rs index 9030d8a57..608fa0f1d 100644 --- a/src/postings/block_segment_postings.rs +++ b/src/postings/block_segment_postings.rs @@ -212,14 +212,14 @@ impl BlockSegmentPostings { /// `TERMINATED`. The array is also guaranteed to be aligned on 16 bytes = 128 bits. /// /// This method is useful to run SSE2 linear search. - #[inline(always)] + #[inline] pub(crate) fn docs_aligned(&self) -> &AlignedBuffer { debug_assert!(self.block_is_loaded()); self.doc_decoder.output_aligned() } /// Return the document at index `idx` of the block. - #[inline(always)] + #[inline] pub fn doc(&self, idx: usize) -> u32 { self.doc_decoder.output(idx) } diff --git a/src/postings/compression/vint.rs b/src/postings/compression/vint.rs index 3de43749f..94248ff76 100644 --- a/src/postings/compression/vint.rs +++ b/src/postings/compression/vint.rs @@ -1,4 +1,4 @@ -#[inline(always)] +#[inline] pub fn compress_sorted<'a>(input: &[u32], output: &'a mut [u8], mut offset: u32) -> &'a [u8] { let mut byte_written = 0; for &v in input { @@ -20,7 +20,7 @@ pub fn compress_sorted<'a>(input: &[u32], output: &'a mut [u8], mut offset: u32) &output[..byte_written] } -#[inline(always)] +#[inline] pub(crate) fn compress_unsorted<'a>(input: &[u32], output: &'a mut [u8]) -> &'a [u8] { let mut byte_written = 0; for &v in input { @@ -41,7 +41,7 @@ pub(crate) fn compress_unsorted<'a>(input: &[u32], output: &'a mut [u8]) -> &'a &output[..byte_written] } -#[inline(always)] +#[inline] pub fn uncompress_sorted(compressed_data: &[u8], output: &mut [u32], offset: u32) -> usize { let mut read_byte = 0; let mut result = offset; @@ -61,7 +61,7 @@ pub fn uncompress_sorted(compressed_data: &[u8], output: &mut [u32], offset: u32 read_byte } -#[inline(always)] +#[inline] pub(crate) fn uncompress_unsorted(compressed_data: &[u8], output_arr: &mut [u32]) -> usize { let mut read_byte = 0; for output_mut in output_arr.iter_mut() { diff --git a/src/postings/segment_postings.rs b/src/postings/segment_postings.rs index 3387098c3..67c3aa48a 100644 --- a/src/postings/segment_postings.rs +++ b/src/postings/segment_postings.rs @@ -204,7 +204,7 @@ impl DocSet for SegmentPostings { } /// Return the current document's `DocId`. - #[inline(always)] + #[inline] fn doc(&self) -> DocId { self.block_cursor.doc(self.cur) } diff --git a/src/postings/skip.rs b/src/postings/skip.rs index 8d4310eb2..33b5ca724 100644 --- a/src/postings/skip.rs +++ b/src/postings/skip.rs @@ -6,12 +6,12 @@ use crate::query::BM25Weight; use crate::schema::IndexRecordOption; use crate::{DocId, Score, TERMINATED}; -#[inline(always)] +#[inline] fn encode_block_wand_max_tf(max_tf: u32) -> u8 { max_tf.min(u8::MAX as u32) as u8 } -#[inline(always)] +#[inline] fn decode_block_wand_max_tf(max_tf_code: u8) -> u32 { if max_tf_code == u8::MAX { u32::MAX @@ -20,12 +20,12 @@ fn decode_block_wand_max_tf(max_tf_code: u8) -> u32 { } } -#[inline(always)] +#[inline] fn read_u32(data: &[u8]) -> u32 { u32::from_le_bytes(data[..4].try_into().unwrap()) } -#[inline(always)] +#[inline] fn write_u32(val: u32, buf: &mut Vec) { buf.extend_from_slice(&val.to_le_bytes()); } @@ -163,7 +163,7 @@ impl SkipReader { self.position_offset } - #[inline(always)] + #[inline] pub fn byte_offset(&self) -> usize { self.byte_offset } diff --git a/src/postings/stacker/expull.rs b/src/postings/stacker/expull.rs index 0510eac64..7b0a16a86 100644 --- a/src/postings/stacker/expull.rs +++ b/src/postings/stacker/expull.rs @@ -147,7 +147,7 @@ impl ExpUnrolledLinkedList { } } - #[inline(always)] + #[inline] pub fn writer<'a>(&'a mut self, heap: &'a mut MemoryArena) -> ExpUnrolledLinkedListWriter<'a> { ExpUnrolledLinkedListWriter { eull: self, heap } } diff --git a/src/postings/stacker/memory_arena.rs b/src/postings/stacker/memory_arena.rs index 816492d28..0685b2adc 100644 --- a/src/postings/stacker/memory_arena.rs +++ b/src/postings/stacker/memory_arena.rs @@ -132,7 +132,7 @@ impl MemoryArena { self.pages[addr.page_id()].slice_from(addr.page_local_addr()) } - #[inline(always)] + #[inline] pub fn slice_mut(&mut self, addr: Addr, len: usize) -> &mut [u8] { self.pages[addr.page_id()].slice_mut(addr.page_local_addr(), len) } @@ -162,7 +162,7 @@ impl Page { } } - #[inline(always)] + #[inline] fn is_available(&self, len: usize) -> bool { len + self.len <= PAGE_SIZE } diff --git a/src/postings/stacker/term_hashmap.rs b/src/postings/stacker/term_hashmap.rs index 4533f2e2f..503c540c8 100644 --- a/src/postings/stacker/term_hashmap.rs +++ b/src/postings/stacker/term_hashmap.rs @@ -118,7 +118,7 @@ impl TermHashMap { self.table.len() < self.occupied.len() * 3 } - #[inline(always)] + #[inline] fn get_key_value(&self, addr: Addr) -> (&[u8], Addr) { let data = self.heap.slice_from(addr); let key_bytes_len = NativeEndian::read_u16(data) as usize; @@ -126,7 +126,7 @@ impl TermHashMap { (key_bytes, addr.offset(2u32 + key_bytes_len as u32)) } - #[inline(always)] + #[inline] fn get_value_addr_if_key_match(&self, target_key: &[u8], addr: Addr) -> Option { let (stored_key, value_addr) = self.get_key_value(addr); if stored_key == target_key { diff --git a/src/query/bm25.rs b/src/query/bm25.rs index d4371237c..45e3701a5 100644 --- a/src/query/bm25.rs +++ b/src/query/bm25.rs @@ -116,7 +116,7 @@ impl BM25Weight { } } - #[inline(always)] + #[inline] pub fn score(&self, fieldnorm_id: u8, term_freq: u32) -> Score { self.weight * self.tf_factor(fieldnorm_id, term_freq) } @@ -125,7 +125,7 @@ impl BM25Weight { self.score(255u8, 2_013_265_944) } - #[inline(always)] + #[inline] pub(crate) fn tf_factor(&self, fieldnorm_id: u8, term_freq: u32) -> Score { let term_freq = term_freq as Score; let norm = self.cache[fieldnorm_id as usize]; diff --git a/src/query/exclude.rs b/src/query/exclude.rs index a246fe279..295fce777 100644 --- a/src/query/exclude.rs +++ b/src/query/exclude.rs @@ -3,7 +3,7 @@ use crate::query::Scorer; use crate::DocId; use crate::Score; -#[inline(always)] +#[inline] fn is_within(docset: &mut TDocSetExclude, doc: DocId) -> bool { docset.doc() <= doc && docset.seek(doc) == doc }