summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-13 20:47:20 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-13 20:47:20 +0000
commit1abb38260f4e31fc5da2586527c367dee1e384c3 (patch)
tree9a5242f87ebb20e04998b12503cd588e93cc807b /searchlib
parent3da5e19509fcc10d4cdbcc49747cacc7cac2ae2e (diff)
Add noexcept, nodiscard and some constexpr
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.h20
-rw-r--r--searchlib/src/vespa/searchlib/index/field_length_info.h8
-rw-r--r--searchlib/src/vespa/searchlib/index/postinglistcounts.h15
4 files changed, 27 insertions, 28 deletions
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
index 99107749610..90bcaabc7a5 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
@@ -35,8 +35,8 @@ DiskIndex::LookupResult::LookupResult() noexcept
{
}
-DiskIndex::Key::Key() = default;
-DiskIndex::Key::Key(IndexList indexes, vespalib::stringref word) :
+DiskIndex::Key::Key() noexcept = default;
+DiskIndex::Key::Key(IndexList indexes, vespalib::stringref word) noexcept :
_word(word),
_indexes(std::move(indexes))
{
@@ -302,7 +302,7 @@ DiskIndex::readPostingList(const LookupResult &lookupRes) const
SchemaUtil::IndexIterator it(_schema, lookupRes.indexId);
handle->_file = _postingFiles[it.getIndex()].get();
if (handle->_file == nullptr) {
- return PostingListHandle::UP();
+ return {};
}
const uint32_t firstSegment = 0;
const uint32_t numSegments = 0; // means all segments
@@ -316,7 +316,7 @@ DiskIndex::readBitVector(const LookupResult &lookupRes) const
SchemaUtil::IndexIterator it(_schema, lookupRes.indexId);
BitVectorDictionary * dict = _bitVectorDicts[it.getIndex()].get();
if (dict == nullptr) {
- return BitVector::UP();
+ return {};
}
return dict->lookup(lookupRes.wordNum);
}
@@ -330,7 +330,7 @@ DiskIndex::calculateSize()
namespace {
-DiskIndex::LookupResult _G_nothing;
+DiskIndex::LookupResult G_nothing;
class LookupCache {
public:
@@ -352,7 +352,7 @@ public:
return result;
}
}
- return _G_nothing;
+ return G_nothing;
}
private:
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.h b/searchlib/src/vespa/searchlib/diskindex/diskindex.h
index faa562e5809..9672939a741 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.h
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.h
@@ -32,8 +32,8 @@ public:
uint64_t bitOffset;
using UP = std::unique_ptr<LookupResult>;
LookupResult() noexcept;
- bool valid() const { return counts._numDocs > 0; }
- void swap(LookupResult & rhs) {
+ bool valid() const noexcept { return counts._numDocs > 0; }
+ void swap(LookupResult & rhs) noexcept {
std::swap(indexId , rhs.indexId);
std::swap(wordNum , rhs.wordNum);
counts.swap(rhs.counts);
@@ -45,22 +45,22 @@ public:
class Key {
public:
- Key();
- Key(IndexList indexes, vespalib::stringref word);
+ Key() noexcept;
+ Key(IndexList indexes, vespalib::stringref word) noexcept;
Key(const Key &);
Key & operator = (const Key &);
- Key(Key &&) = default;
- Key & operator = (Key &&) = default;
+ Key(Key &&) noexcept = default;
+ Key & operator = (Key &&) noexcept = default;
~Key();
- uint32_t hash() const {
+ uint32_t hash() const noexcept {
return vespalib::hashValue(_word.c_str(), _word.size());
}
- bool operator == (const Key & rhs) const {
+ bool operator == (const Key & rhs) const noexcept {
return _word == rhs._word;
}
void push_back(uint32_t indexId) { _indexes.push_back(indexId); }
- const IndexList & getIndexes() const { return _indexes; }
- const vespalib::string & getWord() const { return _word; }
+ const IndexList & getIndexes() const noexcept { return _indexes; }
+ const vespalib::string & getWord() const noexcept { return _word; }
private:
vespalib::string _word;
IndexList _indexes;
diff --git a/searchlib/src/vespa/searchlib/index/field_length_info.h b/searchlib/src/vespa/searchlib/index/field_length_info.h
index d1fba4bc6d2..03125e99a87 100644
--- a/searchlib/src/vespa/searchlib/index/field_length_info.h
+++ b/searchlib/src/vespa/searchlib/index/field_length_info.h
@@ -15,19 +15,19 @@ private:
uint32_t _num_samples;
public:
- FieldLengthInfo()
+ FieldLengthInfo() noexcept
: FieldLengthInfo(0.0, 0)
{
}
- FieldLengthInfo(double average_field_length, uint32_t num_samples)
+ FieldLengthInfo(double average_field_length, uint32_t num_samples) noexcept
: _average_field_length(average_field_length),
_num_samples(num_samples)
{
}
- double get_average_field_length() const { return _average_field_length; }
- uint32_t get_num_samples() const { return _num_samples; }
+ [[nodiscard]] double get_average_field_length() const noexcept { return _average_field_length; }
+ [[nodiscard]] uint32_t get_num_samples() const noexcept { return _num_samples; }
};
}
diff --git a/searchlib/src/vespa/searchlib/index/postinglistcounts.h b/searchlib/src/vespa/searchlib/index/postinglistcounts.h
index 3d76e8203cb..1e58b2f5ef7 100644
--- a/searchlib/src/vespa/searchlib/index/postinglistcounts.h
+++ b/searchlib/src/vespa/searchlib/index/postinglistcounts.h
@@ -29,15 +29,14 @@ public:
uint32_t _numDocs; // Number of documents in segment
uint32_t _lastDoc; // Last document id in segment
- Segment()
+ Segment() noexcept
: _bitLength(0),
_numDocs(0),
_lastDoc(0)
{ }
bool
- operator==(const Segment &rhs) const
- {
+ operator==(const Segment &rhs) const noexcept {
return (_bitLength == rhs._bitLength &&
_numDocs == rhs._numDocs &&
_lastDoc == rhs._lastDoc);
@@ -59,24 +58,24 @@ public:
*/
std::vector<Segment> _segments;
- PostingListCounts()
+ PostingListCounts() noexcept
: _numDocs(0),
_bitLength(0),
_segments()
{ }
- void swap(PostingListCounts & rhs) {
+ void swap(PostingListCounts & rhs) noexcept {
std::swap(_numDocs, rhs._numDocs);
std::swap(_bitLength, rhs._bitLength);
std::swap(_segments, rhs._segments);
}
- void clear() {
+ void clear() noexcept {
_bitLength = 0;
_numDocs = 0;
_segments.clear();
}
- bool operator==(const PostingListCounts &rhs) const {
+ bool operator==(const PostingListCounts &rhs) const noexcept {
return (_numDocs == rhs._numDocs &&
_bitLength == rhs._bitLength &&
_segments == rhs._segments);
@@ -92,7 +91,7 @@ public:
uint64_t _accNumDocs; // Used by prefix search for now.
PostingListCounts _counts;
- PostingListOffsetAndCounts()
+ PostingListOffsetAndCounts() noexcept
: _offset(0),
_accNumDocs(0u),
_counts()