[dconf-editor] Simplify SchemasUtility.



commit 1b6040567357e24c934b9bfbacf5be5ac0fa384f
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Feb 17 06:55:42 2018 +0100

    Simplify SchemasUtility.

 editor/schemas-utility.vala |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/editor/schemas-utility.vala b/editor/schemas-utility.vala
index f8b1aad..3eb033c 100644
--- a/editor/schemas-utility.vala
+++ b/editor/schemas-utility.vala
@@ -18,35 +18,29 @@
 public class SchemasUtility : Object
 {
     private SettingsSchemaSource? settings_schema_source = SettingsSchemaSource.get_default ();
+    private string [] non_relocatable_schemas = {};
+    private string [] relocatable_schemas = {};
 
-    public bool is_relocatable_schema (string id)
+    construct
     {
-        if (settings_schema_source == null)
-            return false;   // TODO better
-
-        string [] non_relocatable_schemas;
-        string [] relocatable_schemas;
-        ((!) settings_schema_source).list_schemas (true, out non_relocatable_schemas, out 
relocatable_schemas);
+        if (settings_schema_source != null)
+            ((!) settings_schema_source).list_schemas (true, out non_relocatable_schemas, out 
relocatable_schemas);
+    }
 
-        return (id in relocatable_schemas);
+    public bool is_relocatable_schema (string id)
+    {
+        return (settings_schema_source != null) && (id in relocatable_schemas);
     }
 
     public bool is_non_relocatable_schema (string id)
     {
-        if (settings_schema_source == null)
-            return false;   // TODO better
-
-        string [] non_relocatable_schemas;
-        string [] relocatable_schemas;
-        ((!) settings_schema_source).list_schemas (true, out non_relocatable_schemas, out 
relocatable_schemas);
-
-        return (id in non_relocatable_schemas);
+        return (settings_schema_source != null) && (id in non_relocatable_schemas);
     }
 
     public string? get_schema_path (string id)
     {
         if (settings_schema_source == null)
-            return null;   // TODO better
+            return null;   // TODO better?
 
         SettingsSchema? schema = ((!) settings_schema_source).lookup (id, true);
         if (schema == null)


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