+
+static inline void trie_compile_aux(trie_t *trie, uint32_t id,
+ uint32_t first_key, uint32_t last_key,
+ int offset)
+{
+ uint32_t forks[256];
+ uint32_t fork_pos = 0;
+ char current = '\0';
+
+#ifdef CHECK_INTEGRITY
+ assert(strcmp(array_ptr(trie->keys, array_elt(trie->keys_offset, first_key) + offset),
+ array_ptr(trie->c, array_elt(trie->entries, id).c_offset)) == 0);
+#endif
+
+ for (int off_diff = 0 ; fork_pos == 0 ; ++off_diff, ++offset) {
+ current = array_elt(trie->keys, array_elt(trie->keys_offset, first_key) + offset);
+ for (uint32_t i = first_key + 1 ; i < last_key ; ++i) {
+ const char *str = array_ptr(trie->keys, array_elt(trie->keys_offset, i));
+ const char c = str[offset];
+ if (c != current) {
+ array_ensure_capacity_delta(trie->entries, 2);
+ if (fork_pos == 0) {
+ trie_entry_split(trie, id, off_diff);
+ }
+ trie_entry_insert_child(trie, id, trie_add_leaf(trie, str + offset));
+ forks[fork_pos++] = i;
+ current = c;