[baobab/wip/vala: 40/44] Make use of new GHashTable API



commit 811bc4c24f2c5ef91813f8bd2de94859aee0c6ba
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 9ac6631..c8e3007 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -17,27 +17,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 a1f0ee3..2a37ece 100644
--- a/src/baobab-sync-scanner.vala
+++ b/src/baobab-sync-scanner.vala
@@ -11,7 +11,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 076c772..4bfea56 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -67,7 +67,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]