Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Reserve vector when length is known.
Kishore Nallancdfbc4c1b5fa
diff --git a/include/posting_list.h b/include/posting_list.hindex 8f95a0f9..8d39d92b 100644--- a/include/posting_list.h+++ b/include/posting_list.h@@ -89,7 +89,7 @@ private:// maximum number of IDs (and associated offsets) to store in each block before another block is createdconst uint16_t BLOCK_MAX_ELEMENTS;- uint16_t ids_length = 0;+ uint32_t ids_length = 0;block_t root_block;@@ -133,7 +133,7 @@ public:size_t num_blocks() const;- size_t num_ids();+ size_t num_ids() const;uint32_t first_id();diff --git a/src/posting_list.cpp b/src/posting_list.cppindex 526848ec..0fcb771d 100644--- a/src/posting_list.cpp+++ b/src/posting_list.cpp@@ -619,6 +619,7 @@ void posting_list_t::intersect(const std::vector<posting_list_t*>& posting_lists}if(posting_lists.size() == 1) {+ result_ids.reserve(posting_lists[0]->ids_length);auto it = posting_lists[0]->new_iterator();while(it.valid()) {result_ids.push_back(it.id());@@ -939,7 +940,7 @@ uint32_t posting_list_t::advance_smallest2(std::vector<posting_list_t::iterator_return smallest_value;}-size_t posting_list_t::num_ids() {+size_t posting_list_t::num_ids() const {return ids_length;}