[gnome-builder/wip/plugins] fuzzy: handle searches of one character specially
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/plugins] fuzzy: handle searches of one character specially
- Date: Sat, 13 Jun 2015 03:46:06 +0000 (UTC)
commit a18308d15f527115bbd881c592224b588c662f2c
Author: Christian Hergert <christian hergert me>
Date: Fri Jun 12 20:40:05 2015 -0700
fuzzy: handle searches of one character specially
contrib/search/fuzzy.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/contrib/search/fuzzy.c b/contrib/search/fuzzy.c
index 7ec66d3..c805668 100644
--- a/contrib/search/fuzzy.c
+++ b/contrib/search/fuzzy.c
@@ -261,7 +261,7 @@ fuzzy_insert (Fuzzy *fuzzy,
}
item.id = id;
- item.pos = tmp - key;
+ item.pos = (guint)(gsize)(tmp - key);
g_array_append_val (table, item);
}
@@ -440,16 +440,31 @@ fuzzy_match (Fuzzy *fuzzy,
lookup.tables [i++] = table;
}
- g_assert (lookup.n_tables > 0);
+ g_assert (lookup.n_tables == i);
g_assert (lookup.tables [0] != NULL);
- lookup.n_tables = i;
root = lookup.tables [0];
- for (i = 0; i < root->len; i++)
+ if (G_LIKELY (lookup.n_tables > 1))
{
- item = &g_array_index (root, FuzzyItem, i);
- fuzzy_do_match (&lookup, item, 1, 0);
+ for (i = 0; i < root->len; i++)
+ {
+ item = &g_array_index (root, FuzzyItem, i);
+ fuzzy_do_match (&lookup, item, 1, 0);
+ }
+ }
+ else
+ {
+ for (i = 0; i < root->len; i++)
+ {
+ item = &g_array_index (root, FuzzyItem, i);
+ match.key = fuzzy_get_string (fuzzy, item->id);
+ match.value = g_ptr_array_index (fuzzy->id_to_value, item->id);
+ match.score = 0;
+ g_array_append_val (matches, match);
+ }
+
+ goto cleanup;
}
g_hash_table_iter_init (&iter, lookup.matches);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]