From 53ed1804e255c78dd4938fe53d27edf90844bdf1 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 5 May 2017 12:33:58 +0200 Subject: [PATCH] gunixmounts: Speed up mtab processing with libmount libmnt_context is useless. It contains cache which is useful for searching, but it isn't used in our case. Let's use mnt_context_parse_mtab instead directly and the mtab processing will be faster. https://bugzilla.gnome.org/show_bug.cgi?id=781867 --- gio/gunixmounts.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index c7effd607..d20d144e9 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -391,15 +391,13 @@ static GList * _g_get_unix_mounts (void) { struct libmnt_table *table = NULL; - struct libmnt_context *ctxt = NULL; struct libmnt_iter* iter = NULL; struct libmnt_fs *fs = NULL; GUnixMountEntry *mount_entry = NULL; GList *return_list = NULL; - ctxt = mnt_new_context (); - mnt_context_get_mtab (ctxt, &table); - if (!table) + table = mnt_new_table (); + if (mnt_table_parse_mtab (table, NULL) < 0) goto out; iter = mnt_new_iter (MNT_ITER_FORWARD); @@ -435,7 +433,7 @@ _g_get_unix_mounts (void) mnt_free_iter (iter); out: - mnt_free_context (ctxt); + mnt_unref_table (table); return g_list_reverse (return_list); } @@ -875,15 +873,13 @@ static GList * _g_get_unix_mount_points (void) { struct libmnt_table *table = NULL; - struct libmnt_context *ctxt = NULL; struct libmnt_iter* iter = NULL; struct libmnt_fs *fs = NULL; GUnixMountPoint *mount_point = NULL; GList *return_list = NULL; - ctxt = mnt_new_context (); - mnt_context_get_fstab (ctxt, &table); - if (!table) + table = mnt_new_table (); + if (mnt_table_parse_mtab (table, NULL) < 0) goto out; iter = mnt_new_iter (MNT_ITER_FORWARD); @@ -953,7 +949,7 @@ _g_get_unix_mount_points (void) mnt_free_iter (iter); out: - mnt_free_context (ctxt); + mnt_unref_table (table); return g_list_reverse (return_list); }