diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-06-11 00:20:37 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-06-29 20:49:05 +0200 |
commit | 62eb9d319b957c24d322a3641ef91e115f5dbed2 (patch) | |
tree | 210ac0e1882f84a2d4e88fc455744bf5a1c52558 /src/libtracker-fts | |
parent | 81b20c3fc8a13ee147e08ca3e44f6704df6d795b (diff) | |
download | tracker-62eb9d319b957c24d322a3641ef91e115f5dbed2.tar.gz |
libtracker-fts: Avoid static variables
Just keep a per-interface table of FTS properties in order to
calculate weights.
Diffstat (limited to 'src/libtracker-fts')
-rw-r--r-- | src/libtracker-fts/tracker-fts-tokenizer.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libtracker-fts/tracker-fts-tokenizer.c b/src/libtracker-fts/tracker-fts-tokenizer.c index a9f09e8fd..e233fd92d 100644 --- a/src/libtracker-fts/tracker-fts-tokenizer.c +++ b/src/libtracker-fts/tracker-fts-tokenizer.c @@ -275,11 +275,14 @@ static GHashTable * get_fts_weights (TrackerDBInterface *iface, sqlite3_context *context) { - static GHashTable *weights = NULL; - static GMutex mutex; + static GQuark iface_qdata = 0; + GHashTable *weights; int rc = SQLITE_DONE; - g_mutex_lock (&mutex); + if (G_UNLIKELY (iface_qdata == 0)) + iface_qdata = g_quark_from_static_string ("tracker-fts-weights"); + + weights = g_object_get_qdata (G_OBJECT (iface), iface_qdata); if (G_UNLIKELY (weights == NULL)) { TrackerDataManager *manager; @@ -323,9 +326,10 @@ get_fts_weights (TrackerDBInterface *iface, g_hash_table_destroy (weights); weights = NULL; } - } - g_mutex_unlock (&mutex); + g_object_set_qdata_full (G_OBJECT (iface), iface_qdata, + weights, (GDestroyNotify) g_hash_table_unref); + } return weights; } |