+
+static inline void trie_compile_aux(trie_t *trie, uint32_t id,
+ uint32_t first_key, uint32_t last_key,
+ int offset, int initial_diff)
+{
+ uint32_t forks[256];
+ uint32_t fork_pos = 0;
+ char current = '\0';
+
+#ifdef CHECK_INTEGRITY
+ assert(strcmp(key(trie, first_key) + offset, str(trie, entry)) == 0);
+#endif
+
+ for (int off_diff = initial_diff ; fork_pos == 0 ; ++off_diff, ++offset) {
+ current = key(trie, first_key)[offset];
+ for (uint32_t i = first_key + 1 ; i < last_key ; ++i) {
+ const char *ckey = key(trie, i) + offset;
+ const char c = *ckey;
+ 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, ckey));
+ forks[fork_pos++] = i;
+ current = c;