mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2025-02-21 08:21:00 +00:00
[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:
parent
c9021d1bfd
commit
7447181075
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user