[dconf/wip/proxy: 6/12] engine: slightly refactor per-source lock-checking



commit 8d3bdbbe6228f88c24e46fa7da64eb8b6f5c9e74
Author: Allison Lortie <desrt desrt ca>
Date:   Fri Oct 14 09:35:00 2016 +0200

    engine: slightly refactor per-source lock-checking
    
    Write a helper function to answer the question of "does this source have
    any lock for the given key?".  Although this logic is currently trivial,
    it will soon get more complex.

 engine/dconf-engine.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index aca2dd3..251974a 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -345,6 +345,16 @@ dconf_engine_get_state (DConfEngine *engine)
 }
 
 static gboolean
+dconf_engine_source_has_lock (DConfEngineSource *source,
+                              const gchar       *key)
+{
+  if (source->locks == NULL)
+    return FALSE;
+
+  return gvdb_table_has_value (source->locks, key);
+}
+
+static gboolean
 dconf_engine_is_writable_internal (DConfEngine *engine,
                                    const gchar *key)
 {
@@ -370,7 +380,7 @@ dconf_engine_is_writable_internal (DConfEngine *engine,
    * thing to do, or it's non-writable and we caught that case above.
    */
   for (i = 1; i < engine->n_sources; i++)
-    if (engine->sources[i]->locks && gvdb_table_has_value (engine->sources[i]->locks, key))
+    if (dconf_engine_source_has_lock (engine->sources[i], key))
       return FALSE;
 
   return TRUE;
@@ -599,7 +609,7 @@ dconf_engine_read (DConfEngine    *engine,
    */
   if (~flags & DCONF_READ_USER_VALUE)
     for (i = engine->n_sources - 1; i > 0; i--)
-      if (engine->sources[i]->locks && gvdb_table_has_value (engine->sources[i]->locks, key))
+      if (dconf_engine_source_has_lock (engine->sources[i], key))
         {
           lock_level = i;
           break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]