[tracker/wip/carlosg/domain-ontologies: 11/76] libtracker-fts: Avoid static variables
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 11/76] libtracker-fts: Avoid static variables
- Date: Thu, 29 Jun 2017 18:50:31 +0000 (UTC)
commit 62eb9d319b957c24d322a3641ef91e115f5dbed2
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jun 11 00:20:37 2017 +0200
libtracker-fts: Avoid static variables
Just keep a per-interface table of FTS properties in order to
calculate weights.
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 a9f09e8..e233fd9 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]