Avoid function call if no partial key
This commit is contained in:
@@ -1125,13 +1125,8 @@ Node *getFirstChildExists(Node *self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consume any partial key of `self`, and update `self` and
|
void consumePartialKeyFull(Node *&self, std::span<const uint8_t> &key,
|
||||||
// `key` such that `self` is along the search path of `key`
|
InternalVersionT writeVersion, WriteContext *tls) {
|
||||||
void consumePartialKey(Node *&self, std::span<const uint8_t> &key,
|
|
||||||
InternalVersionT writeVersion, WriteContext *tls) {
|
|
||||||
if (self->partialKeyLen == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Handle an existing partial key
|
// Handle an existing partial key
|
||||||
int commonLen = std::min<int>(self->partialKeyLen, key.size());
|
int commonLen = std::min<int>(self->partialKeyLen, key.size());
|
||||||
int partialKeyIndex =
|
int partialKeyIndex =
|
||||||
@@ -1172,6 +1167,16 @@ void consumePartialKey(Node *&self, std::span<const uint8_t> &key,
|
|||||||
key = key.subspan(partialKeyIndex, key.size() - partialKeyIndex);
|
key = key.subspan(partialKeyIndex, key.size() - partialKeyIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Consume any partial key of `self`, and update `self` and
|
||||||
|
// `key` such that `self` is along the search path of `key`
|
||||||
|
inline __attribute__((always_inline)) void
|
||||||
|
consumePartialKey(Node *&self, std::span<const uint8_t> &key,
|
||||||
|
InternalVersionT writeVersion, WriteContext *tls) {
|
||||||
|
if (self->partialKeyLen > 0) {
|
||||||
|
consumePartialKeyFull(self, key, writeVersion, tls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Caller is responsible for assigning a non-null pointer to the returned
|
// Caller is responsible for assigning a non-null pointer to the returned
|
||||||
// reference if null. Updates child's max version to `newMaxVersion` if child
|
// reference if null. Updates child's max version to `newMaxVersion` if child
|
||||||
// exists but does not have a partial key.
|
// exists but does not have a partial key.
|
||||||
|
Reference in New Issue
Block a user