diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-05-06 14:46:07 +0200 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-05-06 14:46:07 +0200 |
commit | 81ac70655d1f41cf9db63c94387e04cf6a5cbf65 (patch) | |
tree | f9fdf8982d152a9f02dceb65c418730adbdd0adb /engine/dconf-engine.c | |
parent | 3fed06a5890cfebcb8c8658e989c65a0d5c81b5e (diff) | |
download | dconf-81ac70655d1f41cf9db63c94387e04cf6a5cbf65.tar.gz |
Optimise is_writable() for the common case
...of no system defaults database.
Diffstat (limited to 'engine/dconf-engine.c')
-rw-r--r-- | engine/dconf-engine.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c index 9e7d4b2..ec99116 100644 --- a/engine/dconf-engine.c +++ b/engine/dconf-engine.c @@ -536,24 +536,27 @@ dconf_engine_is_writable (DConfEngine *engine, const gchar *name) { gboolean writable = TRUE; - gint i; - g_static_mutex_lock (&engine->lock); + /* Only check if we have at least one system database */ + if (engine->n_dbs > 1) + { + gint i; - dconf_engine_refresh (engine); + g_static_mutex_lock (&engine->lock); - /* Don't check for locks in the user database. - * If there is only a user database then the loop won't run at all. - */ - for (i = engine->n_dbs - 1; 0 < i; i--) - if (engine->lock_tables[i] != NULL && - gvdb_table_has_value (engine->lock_tables[i], name)) - { - writable = FALSE; - break; - } + dconf_engine_refresh_system (engine); - g_static_mutex_unlock (&engine->lock); + /* Don't check for locks in the user database (i == 0). */ + for (i = engine->n_dbs - 1; 0 < i; i--) + if (engine->lock_tables[i] != NULL && + gvdb_table_has_value (engine->lock_tables[i], name)) + { + writable = FALSE; + break; + } + + g_static_mutex_unlock (&engine->lock); + } return writable; } |