From 020779f61b3dfb982c82aec3324948151c2a58eb Mon Sep 17 00:00:00 2001 From: Laurentiu Nicola Date: Sat, 20 May 2017 20:56:37 +0300 Subject: [PATCH] Make things faster --- src/fastfield/delete.rs | 1 + src/postings/segment_postings.rs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fastfield/delete.rs b/src/fastfield/delete.rs index 8923437c8..d5ab7cbc9 100644 --- a/src/fastfield/delete.rs +++ b/src/fastfield/delete.rs @@ -66,6 +66,7 @@ impl DeleteBitSet { } /// Returns true iff the document is deleted. + #[inline] pub fn is_deleted(&self, doc: DocId) -> bool { if self.len == 0 { false diff --git a/src/postings/segment_postings.rs b/src/postings/segment_postings.rs index 3f35a439e..86eaa7a14 100644 --- a/src/postings/segment_postings.rs +++ b/src/postings/segment_postings.rs @@ -87,9 +87,9 @@ impl<'a> DocSet for SegmentPostings<'a> { // skip blocks until one that might contain the target loop { // check if we need to go to the next block - let last_doc_in_block = { + let (current_doc, last_doc_in_block) = { let block_docs = self.block_cursor.docs(); - block_docs[block_docs.len() - 1] + (block_docs[self.cur], block_docs[block_docs.len() - 1]) }; if target > last_doc_in_block { if !self.block_cursor.advance() { @@ -97,8 +97,7 @@ impl<'a> DocSet for SegmentPostings<'a> { } self.cur = 0; } else { - let block_docs = self.block_cursor.docs(); - if target < block_docs[self.cur] { + if target < current_doc { // We've overpassed the target after the first `advance` call // or we're at the beginning of a block. // Either way, we're on the first `DocId` greater than `target` @@ -226,12 +225,13 @@ impl<'a> BlockSegmentPostings<'a> { self.len = len; } - /// Returns the array of docs in the current block. + #[inline] pub fn docs(&self) -> &[DocId] { self.block_decoder.output_array() } + #[inline] pub fn freq_handler(&self) -> &FreqHandler { &self.freq_handler }