summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-09-26 12:24:29 +0200
committerGitHub <noreply@github.com>2023-09-26 12:24:29 +0200
commit589f8faf81c9ed1ace32ffb67653d2bc9b95cc51 (patch)
tree2b20aee35dda739c8921a7b4c412fff96897c999 /vespalib
parentd186922bea9bb26d9ab59182a9bf12340c024579 (diff)
parent40940483b8f551d2284f582bbb4af07a1c18ac87 (diff)
Merge pull request #28654 from vespa-engine/balder/return-early-on-match
- Return early in doSeek if docId found.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreeiterator.h10
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreeiterator.hpp8
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreenode.h18
3 files changed, 17 insertions, 19 deletions
diff --git a/vespalib/src/vespa/vespalib/btree/btreeiterator.h b/vespalib/src/vespa/vespalib/btree/btreeiterator.h
index 2418da18c23..9480e5880e0 100644
--- a/vespalib/src/vespa/vespalib/btree/btreeiterator.h
+++ b/vespalib/src/vespa/vespalib/btree/btreeiterator.h
@@ -302,22 +302,22 @@ public:
/**
* Get key at current iterator location.
*/
- const KeyType & getKey() const { return _leaf.getKey(); }
+ const KeyType & getKey() const noexcept { return _leaf.getKey(); }
/**
* Get data at current iterator location.
*/
- const DataType & getData() const { return _leaf.getData(); }
+ const DataType & getData() const noexcept { return _leaf.getData(); }
/**
* Check if iterator is at a valid element, i.e. not at end.
*/
- bool valid() const { return _leaf.valid(); }
+ bool valid() const noexcept{ return _leaf.valid(); }
/**
* Return the number of elements in the tree.
*/
- size_t size() const;
+ size_t size() const noexcept;
/**
@@ -333,7 +333,7 @@ public:
/**
* Return if the tree has data or not (e.g. keys and data or only keys).
*/
- static bool hasData() { return LeafNodeType::hasData(); }
+ static bool hasData() noexcept { return LeafNodeType::hasData(); }
/**
* Move the iterator directly to end. Used by findHelper method in BTree.
diff --git a/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp b/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp
index b7927feaa1a..d6dda0047ce 100644
--- a/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp
+++ b/vespalib/src/vespa/vespalib/btree/btreeiterator.hpp
@@ -387,15 +387,13 @@ position(uint32_t levels) const
res += inode->validLeaves();
for (uint32_t c = elem.getIdx(); c < slots; ++c) {
BTreeNode::Ref node = inode->getChild(c);
- const InternalNodeType *jnode =
- _allocator->mapInternalRef(node);
+ const InternalNodeType *jnode = _allocator->mapInternalRef(node);
res -= jnode->validLeaves();
}
} else {
for (uint32_t c = 0; c < elem.getIdx(); ++c) {
BTreeNode::Ref node = inode->getChild(c);
- const InternalNodeType *jnode =
- _allocator->mapInternalRef(node);
+ const InternalNodeType *jnode = _allocator->mapInternalRef(node);
res += jnode->validLeaves();
}
}
@@ -484,7 +482,7 @@ template <typename KeyT, typename DataT, typename AggrT,
uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE>
size_t
BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>::
-size() const
+size() const noexcept
{
if (_pathSize > 0) {
return _path[_pathSize - 1].getNode()->validLeaves();
diff --git a/vespalib/src/vespa/vespalib/btree/btreenode.h b/vespalib/src/vespa/vespalib/btree/btreenode.h
index 0a77a0b4685..4931021d771 100644
--- a/vespalib/src/vespa/vespalib/btree/btreenode.h
+++ b/vespalib/src/vespa/vespalib/btree/btreenode.h
@@ -67,14 +67,14 @@ public:
using Ref = datastore::EntryRef;
using ChildRef = datastore::AtomicEntryRef;
- bool isLeaf() const { return _level == 0u; }
- bool getFrozen() const { return _isFrozen; }
- void freeze() { _isFrozen = true; }
- void unFreeze() { _isFrozen = false; }
- void setLevel(uint8_t level) { _level = level; }
- uint32_t getLevel() const { return _level; }
- uint32_t validSlots() const { return _validSlots; }
- void setValidSlots(uint16_t validSlots_) { _validSlots = validSlots_; }
+ bool isLeaf() const noexcept { return _level == 0u; }
+ bool getFrozen() const noexcept { return _isFrozen; }
+ void freeze() noexcept { _isFrozen = true; }
+ void unFreeze() noexcept { _isFrozen = false; }
+ void setLevel(uint8_t level) noexcept { _level = level; }
+ uint32_t getLevel() const noexcept { return _level; }
+ uint32_t validSlots() const noexcept { return _validSlots; }
+ void setValidSlots(uint16_t validSlots_) noexcept { _validSlots = validSlots_; }
};
@@ -358,7 +358,7 @@ public:
void insert(uint32_t idx, const KeyT & key, BTreeNode::Ref child) {
insert(idx, key, BTreeNode::ChildRef(child));
}
- uint32_t validLeaves() const { return _validLeaves; }
+ uint32_t validLeaves() const noexcept { return _validLeaves; }
void setValidLeaves(uint32_t newValidLeaves) { _validLeaves = newValidLeaves; }
void incValidLeaves(uint32_t delta) { _validLeaves += delta; }
void decValidLeaves(uint32_t delta) { _validLeaves -= delta; }