[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.

Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
Tyrann 2006-09-10 19:08:51 +09:30
parent c9021d1bfd
commit 7447181075
2 changed files with 4 additions and 1 deletions

View File

@ -126,6 +126,8 @@ ST_Insert(struct rb_string_root *root, struct rb_string_node *node)
len = strlen(node->string);
if (len > root->maxlen)
root->maxlen = len;
if (len < root->minlen)
root->minlen = len;
rb_link_node(&node->node, parent, p);
rb_insert_color(&node->node, &root->root);

View File

@ -31,10 +31,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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