From d42d3e977267dcf2f233381cc2f49f3628adf4e4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 31 Aug 2023 15:26:31 +0100 Subject: [PATCH] dir: Use g_strv_equal() This was new in GLib 2.60, but libglnx now provides a backport, so we can use it unconditionally. We still need a wrapper because g_strv_equal() is not NULL-safe, but it's a very thin wrapper now. Signed-off-by: Simon McVittie --- common/flatpak-dir.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 242a03fe..2ce8ea5b 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -10299,26 +10299,15 @@ flatpak_dir_install_bundle (FlatpakDir *self, } static gboolean -_g_strv_equal0 (gchar **a, gchar **b) +_g_strv_equal0 (const char * const *a, const char * const *b) { - gboolean ret = FALSE; - guint n; - if (a == NULL && b == NULL) - { - ret = TRUE; - goto out; - } + return TRUE; + if (a == NULL || b == NULL) - goto out; - if (g_strv_length (a) != g_strv_length (b)) - goto out; - for (n = 0; a[n] != NULL; n++) - if (g_strcmp0 (a[n], b[n]) != 0) - goto out; - ret = TRUE; -out: - return ret; + return FALSE; + + return g_strv_equal (a, b); } gboolean @@ -10381,7 +10370,7 @@ flatpak_dir_needs_update_for_commit_and_subpaths (FlatpakDir *self, /* target commit is the same as current, but maybe something else that is different? */ /* Same commit, but different subpaths => update */ - if (!_g_strv_equal0 ((char **) subpaths, (char **) old_subpaths)) + if (!_g_strv_equal0 (subpaths, old_subpaths)) return TRUE; /* Same subpaths and commit, no need to update */