+ if (fork_pos == 0 && current == '\0') {
+ return;
+ }
+ }
+ forks[fork_pos] = last_key;
+
+ const int children_len = array_elt(trie->entries, id).children_len;
+ for (int i = 0 ; i < children_len ; ++i) {
+ int child = array_elt(trie->entries, id).children_offset + i;
+ if (forks[i] - 1 > first_key) {
+ trie_compile_aux(trie, child, first_key, forks[i], offset, 1);
+ }
+ first_key = forks[i];
+ }
+}
+
+void trie_compile(trie_t *trie, bool memlock)
+{
+ assert(trie->entries.len == 0 && "Trie already compiled");
+ assert(trie->keys.len != 0 && "Trying to compile an empty trie");
+ {
+# define QSORT_TYPE int
+# define QSORT_BASE trie->keys_offset.data
+# define QSORT_NELT trie->keys_offset.len
+# define QSORT_LT(a,b) strcmp(trie->keys.data + *a, trie->keys.data + *b) < 0
+# include "qsort.c"
+ }
+
+ array_ensure_capacity(trie->entries, trie->keys.len);
+ trie_compile_aux(trie, trie_add_leaf(trie, trie->keys.data),
+ 0, trie->keys_offset.len, 0, 0);
+ trie_cleanup_build_data(trie);
+ array_adjust(trie->entries);
+ array_adjust(trie->c);
+ if (memlock) {
+ trie_lock(trie);