<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">[PATCH] Track minimum string length in string trees

Keep track of the shortest string in our string trees. This info is helpful
for string completion.

diff -urN b/common/shell.c head/common/shell.c
--- b/common/shell.c	2006-02-18 11:34:50.000000000 +1030
+++ head/common/shell.c	2006-02-15 14:47:30.000000000 +1030
@@ -126,6 +126,8 @@
     len = strlen(node-&gt;string);
     if (len &gt; root-&gt;maxlen)
 	root-&gt;maxlen = len;
+    if (len &lt; root-&gt;minlen)
+	root-&gt;minlen = len;
     rb_link_node(&amp;node-&gt;node, parent, p);
     rb_insert_color(&amp;node-&gt;node, &amp;root-&gt;root);
 
diff -urN b/include/shell.h head/include/shell.h
--- b/include/shell.h	2006-01-22 12:17:30.000000000 +1030
+++ head/include/shell.h	2006-02-15 12:22:41.000000000 +1030
@@ -31,10 +31,11 @@
 struct rb_string_root {
     unsigned int entries;
     unsigned int maxlen;
+    unsigned int minlen;
     struct rb_root root;
 };
 
-#define RB_STRING_ROOT (struct rb_string_root) { 0, 0, RB_ROOT }
+#define RB_STRING_ROOT (struct rb_string_root) { 0, 0, -1, RB_ROOT }
 
 /*
  * String node is simply an rb_tree node using the string as the index (and
</pre></body></html>