Removed all inline(always) like a baboon.

This commit is contained in:
Paul Masurel
2021-04-23 10:47:13 +09:00
parent 1ebfc71721
commit 18bfe131fe
16 changed files with 42 additions and 42 deletions
+2 -2
View File
@@ -180,7 +180,7 @@ impl<T: PartialOrd + Clone> TopSegmentCollector<T> {
/// 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<T: PartialOrd + Clone> TopSegmentCollector<T> {
///
/// 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.
+6 -6
View File
@@ -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<u32> {
if self.is_empty() {
None
+4 -4
View File
@@ -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
+4 -4
View File
@@ -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..]
}
+1 -1
View File
@@ -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];
+2 -2
View File
@@ -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)
+3 -3
View File
@@ -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)
}
+2 -2
View File
@@ -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)
}
+4 -4
View File
@@ -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() {
+1 -1
View File
@@ -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)
}
+5 -5
View File
@@ -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<u8>) {
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
}
+1 -1
View File
@@ -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 }
}
+2 -2
View File
@@ -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
}
+2 -2
View File
@@ -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<Addr> {
let (stored_key, value_addr) = self.get_key_value(addr);
if stored_key == target_key {
+2 -2
View File
@@ -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];
+1 -1
View File
@@ -3,7 +3,7 @@ use crate::query::Scorer;
use crate::DocId;
use crate::Score;
#[inline(always)]
#[inline]
fn is_within<TDocSetExclude: DocSet>(docset: &mut TDocSetExclude, doc: DocId) -> bool {
docset.doc() <= doc && docset.seek(doc) == doc
}