[gnome-builder/gnome-builder-42] libide/foundry: avoid rewriting arg when possible



commit aa28fd512a1a33f566dba62bfbbb399f3d548806
Author: Christian Hergert <chergert redhat com>
Date:   Tue Apr 5 13:19:42 2022 -0700

    libide/foundry: avoid rewriting arg when possible

 src/libide/foundry/ide-runtime.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/libide/foundry/ide-runtime.c b/src/libide/foundry/ide-runtime.c
index a1dd19ca3..f58b29718 100644
--- a/src/libide/foundry/ide-runtime.c
+++ b/src/libide/foundry/ide-runtime.c
@@ -247,17 +247,21 @@ ide_runtime_real_create_runner (IdeRuntime     *self,
   if (argv && argv[0] && !g_path_is_absolute (argv[0]))
     {
       const gchar *slash = strchr (argv[0], '/');
-      g_autofree gchar *copy = g_strdup (slash ? (slash + 1) : argv[0]);
 
-      g_free (argv[0]);
-
-      if (installdir != NULL)
+      if (slash != NULL)
         {
-          g_autoptr(GFile) dest = g_file_get_child (installdir, copy);
-          argv[0] = g_file_get_path (dest);
+          g_autofree gchar *copy = g_strdup (slash ? (slash + 1) : argv[0]);
+
+          g_free (argv[0]);
+
+          if (installdir != NULL)
+            {
+              g_autoptr(GFile) dest = g_file_get_child (installdir, copy);
+              argv[0] = g_file_get_path (dest);
+            }
+          else
+            argv[0] = g_steal_pointer (&copy);
         }
-      else
-        argv[0] = g_steal_pointer (&copy);
     }
 
   if (installdir != NULL)


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