[tracker] Make tracker_hal_path_is_on_removable_device() a bit more performant.



commit bb82caae61dbf786b295dcc8bb969f73af20bfb6
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 4 17:56:58 2009 +0200

    Make tracker_hal_path_is_on_removable_device() a bit more performant.
---
 src/libtracker-common/tracker-hal.c |   39 ++++++++++------------------------
 1 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/src/libtracker-common/tracker-hal.c b/src/libtracker-common/tracker-hal.c
index 10ba038..f8a35d9 100644
--- a/src/libtracker-common/tracker-hal.c
+++ b/src/libtracker-common/tracker-hal.c
@@ -1187,39 +1187,24 @@ tracker_hal_uri_is_on_removable_device (TrackerHal  *hal,
 	g_hash_table_iter_init (&iter, priv->removable_devices);
 
 	while (g_hash_table_iter_next (&iter, &key, &value)) {
-		LibHalVolume  *volume;
-		const gchar   *udi;
-		const gchar   *mp;
-
-		udi = key;
-
-		volume = libhal_volume_from_udi (priv->context, udi);
-
-		if (!volume) {
-			g_message ("HAL device with udi:'%s' has no volume, "
-				   "should we delete?",
-				   udi);
-			continue;
-		}
-
-		mp = libhal_volume_get_mount_point (volume);
+		const gchar *mp;
 
-		if (g_strcmp0 (mp, path) != 0) {
-			if (g_strrstr (path, mp)) {
-				found = TRUE;
+		mp = value;
 
-				if (mount_point)
-					*mount_point = g_strdup (mp);
+		if (mp && path &&
+		    g_str_has_prefix (path, mp)) {
+			found = TRUE;
 
-				if (available)
-					*available = libhal_volume_is_mounted (volume);
+			if (mount_point) {
+				*mount_point = g_strdup (mp);
+			}
 
-				libhal_volume_free (volume);
-				break;
+			if (available) {
+				*available = TRUE;
 			}
-		}
 
-		libhal_volume_free (volume);
+			break;
+		}
 	}
 
 	g_free (path);



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