[baobab/wip/vala: 23/53] Make use of new GHashTable API



commit ada5fcde5a36447539aab0f3b7304e26dee82723
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Jan 6 10:31:50 2012 -0500

    Make use of new GHashTable API
    
    Use the new GHashTable APIs just added to GLib.  This requires the
    latest git versions of GLib and Vala to build.
    
    Also, don't add '/selinux' to the excluded list twice.

 src/baobab-application.vala      |   15 +++++----------
 src/baobab-sync-scanner.vala     |    2 +-
 src/baobab-threaded-scanner.vala |    2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index b96772b..849b687 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -36,27 +36,22 @@ namespace Baobab {
 			}
 		}
 
-		static void add_excluded_location (HashTable<File, unowned File> table, File file) {
-			table.insert (file, file);
-		}
-
 		public static HashTable<File, unowned File> get_excluded_locations () {
 			var app = baobab;
 
 			var excluded_locations = new HashTable<File, unowned File> (file_hash, file_equal);
-			add_excluded_location (excluded_locations, File.new_for_path ("/proc"));
-			add_excluded_location (excluded_locations, File.new_for_path ("/sys"));
-			add_excluded_location (excluded_locations, File.new_for_path ("/selinux"));
-			add_excluded_location (excluded_locations, File.new_for_path ("/selinux"));
+			excluded_locations.add (File.new_for_path ("/proc"));
+			excluded_locations.add (File.new_for_path ("/sys"));
+			excluded_locations.add (File.new_for_path ("/selinux"));
 
 			var home = File.new_for_path (Environment.get_home_dir ());
-			add_excluded_location (excluded_locations, home.get_child (".gvfs"));
+			excluded_locations.add (home.get_child (".gvfs"));
 
 			var root = File.new_for_path ("/");
 			foreach (var uri in app.prefs_settings.get_value ("excluded-uris")) {
 				var file = File.new_for_uri ((string) uri);
 				if (!file.equal (root)) {
-					excluded_locations.insert (file, file);
+					excluded_locations.add (file);
 				}
 			}
 
diff --git a/src/baobab-sync-scanner.vala b/src/baobab-sync-scanner.vala
index 4cc5bd6..2b8ade4 100644
--- a/src/baobab-sync-scanner.vala
+++ b/src/baobab-sync-scanner.vala
@@ -31,7 +31,7 @@ namespace Baobab {
 			var results = Results ();
 			Gtk.TreeIter iter;
 
-			if (excluded_locations.lookup (directory) != null) {
+			if (directory in excluded_locations) {
 				return results;
 			}
 
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index 09980f2..0f2431f 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -87,7 +87,7 @@ namespace Baobab {
 		Results? add_directory (File directory, FileInfo info, Results? parent = null) {
 			var results_array = new ResultsArray ();
 
-			if (excluded_locations.lookup (directory) != null) {
+			if (directory in excluded_locations) {
 				return null;
 			}
 



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