From 359b0b29ff45706296d75d90f07c2b39e04851d5 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 12 Aug 2024 16:33:03 -0700 Subject: [PATCH] Avoid function call if no partial key --- ConflictSet.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 0b69e9e..19f7f0f 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1125,13 +1125,8 @@ Node *getFirstChildExists(Node *self) { } } -// Consume any partial key of `self`, and update `self` and -// `key` such that `self` is along the search path of `key` -void consumePartialKey(Node *&self, std::span &key, - InternalVersionT writeVersion, WriteContext *tls) { - if (self->partialKeyLen == 0) { - return; - } +void consumePartialKeyFull(Node *&self, std::span &key, + InternalVersionT writeVersion, WriteContext *tls) { // Handle an existing partial key int commonLen = std::min(self->partialKeyLen, key.size()); int partialKeyIndex = @@ -1172,6 +1167,16 @@ void consumePartialKey(Node *&self, std::span &key, 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 &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 // reference if null. Updates child's max version to `newMaxVersion` if child // exists but does not have a partial key.