summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-20 13:52:22 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-20 13:52:22 -0400
commit17c2cff2c45dbdf7fea6fa0944afef750e1cb00f (patch)
treeeeb28adc5cb621681c5a924918134d5f54d8ae1b /src
parent35ff93aeab208c3f2b13622e84eb9b11c7195f17 (diff)
downloadbfs-17c2cff2c45dbdf7fea6fa0944afef750e1cb00f.tar.xz
trie: Add some more target_clones wrappers
Diffstat (limited to 'src')
-rw-r--r--src/trie.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/trie.c b/src/trie.c
index 808953e..7504d53 100644
--- a/src/trie.c
+++ b/src/trie.c
@@ -221,7 +221,8 @@ struct trie_leaf *trie_find_str(const struct trie *trie, const char *key) {
return trie_find_mem(trie, key, strlen(key) + 1);
}
-struct trie_leaf *trie_find_mem(const struct trie *trie, const void *key, size_t length) {
+trie_clones
+static struct trie_leaf *trie_find_mem_impl(const struct trie *trie, const void *key, size_t length) {
struct trie_leaf *rep = trie_representative(trie, key, length);
if (rep && rep->length == length && memcmp(rep->key, key, length) == 0) {
return rep;
@@ -230,7 +231,12 @@ struct trie_leaf *trie_find_mem(const struct trie *trie, const void *key, size_t
}
}
-struct trie_leaf *trie_find_postfix(const struct trie *trie, const char *key) {
+struct trie_leaf *trie_find_mem(const struct trie *trie, const void *key, size_t length) {
+ return trie_find_mem_impl(trie, key, length);
+}
+
+trie_clones
+static struct trie_leaf *trie_find_postfix_impl(const struct trie *trie, const char *key) {
size_t length = strlen(key);
struct trie_leaf *rep = trie_representative(trie, key, length + 1);
if (rep && rep->length >= length && memcmp(rep->key, key, length) == 0) {
@@ -240,6 +246,10 @@ struct trie_leaf *trie_find_postfix(const struct trie *trie, const char *key) {
}
}
+struct trie_leaf *trie_find_postfix(const struct trie *trie, const char *key) {
+ return trie_find_postfix_impl(trie, key);
+}
+
/**
* Find a leaf that may end at the current node.
*/