[dconf-editor] Remove dup function.



commit d319d4e232c25955d1d7c5fea3fc2794f60a436c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Jan 31 02:28:15 2018 +0100

    Remove dup function.

 editor/dconf-model.vala     |   26 +++++++++-----------------
 editor/registry-search.vala |    6 +-----
 2 files changed, 10 insertions(+), 22 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 70ea58c..eee6ecc 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -321,34 +321,26 @@ public class SettingsModel : Object
 
     public static string get_base_path (string path)
     {
-        if (!is_key_path (path))
-            return path;
-        else
-            return stripped_path (path);
+        if (path.length <= 1)
+            return "/";
+        return path.slice (0, path.last_index_of_char ('/') + 1);
     }
 
-    private static string get_name (string path)
+    public static string get_name (string path)
     {
-        if (path == "/")
+        if (path.length <= 1)
             return "/";
         if (is_key_path (path))
-            return path [path.last_index_of_char ('/') + 1:path.length];
-        string tmp = path[0:-1];
-        return tmp [tmp.last_index_of_char ('/') + 1:tmp.length];
+            return path [path.last_index_of_char ('/') + 1 : path.length];
+        string tmp = path [0:-1];
+        return tmp [tmp.last_index_of_char ('/') + 1 : tmp.length];
     }
 
     public static string get_parent_path (string path)
     {
-        if (path == "/")
-            return path;
-        return get_base_path (!is_key_path (path) ? path [0:-1] : path);
-    }
-
-    private static string stripped_path (string path)
-    {
         if (path.length <= 1)
             return "/";
-        return path.slice (0, path.last_index_of_char ('/') + 1);
+        return get_base_path (is_key_path (path) ? path : path [0:-1]);
     }
 
     /*\
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 999deb2..bbc1ecc 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -118,11 +118,7 @@ class RegistrySearch : Grid, BrowsableView
         ClickableListBoxRow row;
         SettingObject setting_object = (SettingObject) item;
         string full_name = setting_object.full_name;
-        string parent_path;
-        if (!SettingsModel.is_key_path (full_name))
-            parent_path = SettingsModel.get_base_path (full_name [0:full_name.length - 1]);
-        else
-            parent_path = SettingsModel.get_base_path (full_name);
+        string parent_path = SettingsModel.get_parent_path (full_name);
         bool is_local_result = parent_path == current_path;
 
         if (setting_object is Directory)


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