[glib: 1/2] Port internal uses to use g_source_set_static_name()




commit 8e963e0e317b02c4f912d8b989c75707a48aba6f
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Jul 26 10:53:02 2021 +0100

    Port internal uses to use g_source_set_static_name()
    
    This should reduce allocations.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/gactiongroupexporter.c   |  2 +-
 gio/gcancellable.c           |  2 +-
 gio/gdbusconnection.c        | 18 +++++++++---------
 gio/gdbusnameowning.c        |  2 +-
 gio/gdbusnamewatching.c      |  2 +-
 gio/gdbusprivate.c           |  6 +++---
 gio/gdbusserver.c            |  2 +-
 gio/gioscheduler.c           |  4 ++--
 gio/glocalfileinfo.c         |  4 ++--
 gio/glocalfilemonitor.c      |  2 +-
 gio/gnetworkmonitorbase.c    |  2 +-
 gio/gpollableutils.c         |  2 +-
 gio/gsimpleasyncresult.c     |  4 ++--
 gio/gsocket.c                |  2 +-
 gio/gtask.c                  |  2 +-
 gio/gunixmounts.c            |  2 +-
 gio/inotify/inotify-kernel.c |  2 +-
 glib/giounix.c               |  2 +-
 glib/giowin32.c              |  2 +-
 glib/gmain.c                 |  6 +++---
 glib/tests/mainloop.c        |  2 +-
 tests/mainloop-test.c        |  8 ++++----
 22 files changed, 40 insertions(+), 40 deletions(-)
---
diff --git a/gio/gactiongroupexporter.c b/gio/gactiongroupexporter.c
index 8453723f5..d1c1903e8 100644
--- a/gio/gactiongroupexporter.c
+++ b/gio/gactiongroupexporter.c
@@ -249,7 +249,7 @@ g_action_group_exporter_set_events (GActionGroupExporter *exporter,
       source = g_idle_source_new ();
       exporter->pending_source = source;
       g_source_set_callback (source, g_action_group_exporter_dispatch_events, exporter, NULL);
-      g_source_set_name (source, "[gio] g_action_group_exporter_dispatch_events");
+      g_source_set_static_name (source, "[gio] g_action_group_exporter_dispatch_events");
       g_source_attach (source, exporter->context);
       g_source_unref (source);
     }
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index a084282ec..b96e948df 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -798,7 +798,7 @@ g_cancellable_source_new (GCancellable *cancellable)
   GCancellableSource *cancellable_source;
 
   source = g_source_new (&cancellable_source_funcs, sizeof (GCancellableSource));
-  g_source_set_name (source, "GCancellable");
+  g_source_set_static_name (source, "GCancellable");
   g_source_set_dispose_function (source, cancellable_source_dispose);
   cancellable_source = (GCancellableSource *)source;
 
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index 8ce70a93d..d730111f8 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -275,7 +275,7 @@ call_destroy_notify (GMainContext  *context,
                          call_destroy_notify_data_in_idle,
                          data,
                          (GDestroyNotify) call_destroy_notify_data_free);
-  g_source_set_name (idle_source, "[gio] call_destroy_notify_data_in_idle");
+  g_source_set_static_name (idle_source, "[gio] call_destroy_notify_data_in_idle");
   g_source_attach (idle_source, context);
   g_source_unref (idle_source);
 }
@@ -1418,7 +1418,7 @@ schedule_closed_unlocked (GDBusConnection *connection,
                          emit_closed_in_idle,
                          data,
                          (GDestroyNotify) emit_closed_data_free);
-  g_source_set_name (idle_source, "[gio] emit_closed_in_idle");
+  g_source_set_static_name (idle_source, "[gio] emit_closed_in_idle");
   g_source_attach (idle_source, connection->main_context_at_construction);
   g_source_unref (idle_source);
 }
@@ -1885,7 +1885,7 @@ send_message_with_reply_cancelled_cb (GCancellable *cancellable,
    * via g_cancellable_connect() (e.g. holding lock)
    */
   idle_source = g_idle_source_new ();
-  g_source_set_name (idle_source, "[gio] send_message_with_reply_cancelled_idle_cb");
+  g_source_set_static_name (idle_source, "[gio] send_message_with_reply_cancelled_idle_cb");
   g_task_attach_source (task, idle_source, send_message_with_reply_cancelled_idle_cb);
   g_source_unref (idle_source);
 }
@@ -3954,7 +3954,7 @@ schedule_callbacks (GDBusConnection *connection,
                                  emit_signal_instance_in_idle_cb,
                                  signal_instance,
                                  (GDestroyNotify) signal_instance_free);
-          g_source_set_name (idle_source, "[gio] emit_signal_instance_in_idle_cb");
+          g_source_set_static_name (idle_source, "[gio] emit_signal_instance_in_idle_cb");
           g_source_attach (idle_source, subscriber->context);
           g_source_unref (idle_source);
         }
@@ -4429,9 +4429,9 @@ validate_and_maybe_schedule_property_getset (GDBusConnection            *connect
                          property_data,
                          (GDestroyNotify) property_data_free);
   if (is_get)
-    g_source_set_name (idle_source, "[gio] invoke_get_property_in_idle_cb");
+    g_source_set_static_name (idle_source, "[gio] invoke_get_property_in_idle_cb");
   else
-    g_source_set_name (idle_source, "[gio] invoke_set_property_in_idle_cb");
+    g_source_set_static_name (idle_source, "[gio] invoke_set_property_in_idle_cb");
   g_source_attach (idle_source, main_context);
   g_source_unref (idle_source);
 
@@ -4649,7 +4649,7 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection            *connec
                          invoke_get_all_properties_in_idle_cb,
                          property_get_all_data,
                          (GDestroyNotify) property_get_all_data_free);
-  g_source_set_name (idle_source, "[gio] invoke_get_all_properties_in_idle_cb");
+  g_source_set_static_name (idle_source, "[gio] invoke_get_all_properties_in_idle_cb");
   g_source_attach (idle_source, main_context);
   g_source_unref (idle_source);
 
@@ -4966,7 +4966,7 @@ schedule_method_call (GDBusConnection            *connection,
                          call_in_idle_cb,
                          invocation,
                          g_object_unref);
-  g_source_set_name (idle_source, "[gio, " __FILE__ "] call_in_idle_cb");
+  g_source_set_static_name (idle_source, "[gio, " __FILE__ "] call_in_idle_cb");
   g_source_attach (idle_source, main_context);
   g_source_unref (idle_source);
 }
@@ -6828,7 +6828,7 @@ subtree_message_func (GDBusConnection *connection,
                          process_subtree_vtable_message_in_idle_cb,
                          data,
                          (GDestroyNotify) subtree_deferred_data_free);
-  g_source_set_name (idle_source, "[gio] process_subtree_vtable_message_in_idle_cb");
+  g_source_set_static_name (idle_source, "[gio] process_subtree_vtable_message_in_idle_cb");
   g_source_attach (idle_source, es->context);
   g_source_unref (idle_source);
 
diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c
index 328354be4..879da0bbe 100644
--- a/gio/gdbusnameowning.c
+++ b/gio/gdbusnameowning.c
@@ -197,7 +197,7 @@ schedule_call_in_idle (Client *client, CallType  call_type)
                          call_in_idle_cb,
                          data,
                          (GDestroyNotify) call_handler_data_free);
-  g_source_set_name (idle_source, "[gio, gdbusnameowning.c] call_in_idle_cb");
+  g_source_set_static_name (idle_source, "[gio, gdbusnameowning.c] call_in_idle_cb");
   g_source_attach (idle_source, client->main_context);
   g_source_unref (idle_source);
 }
diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c
index 40aee5a3c..8daa69cd9 100644
--- a/gio/gdbusnamewatching.c
+++ b/gio/gdbusnamewatching.c
@@ -206,7 +206,7 @@ schedule_call_in_idle (Client *client, CallType call_type)
                          call_in_idle_cb,
                          data,
                          (GDestroyNotify) call_handler_data_free);
-  g_source_set_name (idle_source, "[gio, gdbusnamewatching.c] call_in_idle_cb");
+  g_source_set_static_name (idle_source, "[gio, gdbusnamewatching.c] call_in_idle_cb");
   g_source_attach (idle_source, client->main_context);
   g_source_unref (idle_source);
 }
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 7e62fa89e..fc58aea06 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -554,7 +554,7 @@ _g_dbus_worker_unfreeze (GDBusWorker *worker)
                          unfreeze_in_idle_cb,
                          _g_dbus_worker_ref (worker),
                          (GDestroyNotify) _g_dbus_worker_unref);
-  g_source_set_name (idle_source, "[gio] unfreeze_in_idle_cb");
+  g_source_set_static_name (idle_source, "[gio] unfreeze_in_idle_cb");
   g_source_attach (idle_source, worker->shared_thread_data->context);
   g_source_unref (idle_source);
 }
@@ -1601,7 +1601,7 @@ schedule_writing_unlocked (GDBusWorker        *worker,
                              continue_writing_in_idle_cb,
                              _g_dbus_worker_ref (worker),
                              (GDestroyNotify) _g_dbus_worker_unref);
-      g_source_set_name (idle_source, "[gio] continue_writing_in_idle_cb");
+      g_source_set_static_name (idle_source, "[gio] continue_writing_in_idle_cb");
       g_source_attach (idle_source, worker->shared_thread_data->context);
       g_source_unref (idle_source);
     }
@@ -1696,7 +1696,7 @@ _g_dbus_worker_new (GIOStream                              *stream,
                          _g_dbus_worker_do_initial_read,
                          _g_dbus_worker_ref (worker),
                          (GDestroyNotify) _g_dbus_worker_unref);
-  g_source_set_name (idle_source, "[gio] _g_dbus_worker_do_initial_read");
+  g_source_set_static_name (idle_source, "[gio] _g_dbus_worker_do_initial_read");
   g_source_attach (idle_source, worker->shared_thread_data->context);
   g_source_unref (idle_source);
 
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index 3fdded58a..c83a647f7 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -1085,7 +1085,7 @@ on_run (GSocketService    *service,
                              emit_new_connection_in_idle,
                              data,
                              (GDestroyNotify) emit_idle_data_free);
-      g_source_set_name (idle_source, "[gio] emit_new_connection_in_idle");
+      g_source_set_static_name (idle_source, "[gio] emit_new_connection_in_idle");
       g_source_attach (idle_source, server->main_context_at_construction);
       g_source_unref (idle_source);
     }
diff --git a/gio/gioscheduler.c b/gio/gioscheduler.c
index c146e0796..0367edee8 100644
--- a/gio/gioscheduler.c
+++ b/gio/gioscheduler.c
@@ -261,7 +261,7 @@ g_io_scheduler_job_send_to_mainloop (GIOSchedulerJob *job,
   g_source_set_priority (source, G_PRIORITY_DEFAULT);
   g_source_set_callback (source, mainloop_proxy_func, proxy,
                         NULL);
-  g_source_set_name (source, "[gio] mainloop_proxy_func");
+  g_source_set_static_name (source, "[gio] mainloop_proxy_func");
 
   g_source_attach (source, job->context);
   g_source_unref (source);
@@ -318,7 +318,7 @@ g_io_scheduler_job_send_to_mainloop_async (GIOSchedulerJob *job,
   g_source_set_priority (source, G_PRIORITY_DEFAULT);
   g_source_set_callback (source, mainloop_proxy_func, proxy,
                         (GDestroyNotify)mainloop_proxy_free);
-  g_source_set_name (source, "[gio] mainloop_proxy_func");
+  g_source_set_static_name (source, "[gio] mainloop_proxy_func");
 
   g_source_attach (source, job->context);
   g_source_unref (source);
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 6695fc1df..3867ca684 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1667,8 +1667,8 @@ file_is_hidden (const gchar *path,
             g_timeout_source_new_seconds (hidden_cache_ttl_secs +
                                           hidden_cache_ttl_jitter_secs);
           g_source_set_priority (hidden_cache_source, G_PRIORITY_DEFAULT);
-          g_source_set_name (hidden_cache_source,
-                             "[gio] remove_from_hidden_cache");
+          g_source_set_static_name (hidden_cache_source,
+                                    "[gio] remove_from_hidden_cache");
           g_source_set_callback (hidden_cache_source,
                                  remove_from_hidden_cache,
                                  NULL, NULL);
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index dc32fb660..7e922561a 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -658,7 +658,7 @@ g_file_monitor_source_new (gpointer           instance,
   source = g_source_new (&source_funcs, sizeof (GFileMonitorSource));
   fms = (GFileMonitorSource *) source;
 
-  g_source_set_name (source, "GFileMonitorSource");
+  g_source_set_static_name (source, "GFileMonitorSource");
 
   g_mutex_init (&fms->lock);
   g_weak_ref_init (&fms->instance_ref, instance);
diff --git a/gio/gnetworkmonitorbase.c b/gio/gnetworkmonitorbase.c
index d503759c1..3ad2f9bf6 100644
--- a/gio/gnetworkmonitorbase.c
+++ b/gio/gnetworkmonitorbase.c
@@ -467,7 +467,7 @@ queue_network_changed (GNetworkMonitorBase *monitor)
        */
       g_source_set_priority (source, G_PRIORITY_HIGH_IDLE);
       g_source_set_callback (source, emit_network_changed, monitor, NULL);
-      g_source_set_name (source, "[gio] emit_network_changed");
+      g_source_set_static_name (source, "[gio] emit_network_changed");
       g_source_attach (source, monitor->priv->context);
       monitor->priv->network_changed_source = source;
     }
diff --git a/gio/gpollableutils.c b/gio/gpollableutils.c
index 77bf82174..a20d1505f 100644
--- a/gio/gpollableutils.c
+++ b/gio/gpollableutils.c
@@ -116,7 +116,7 @@ g_pollable_source_new (GObject *pollable_stream)
                        G_IS_POLLABLE_OUTPUT_STREAM (pollable_stream), NULL);
 
   source = g_source_new (&pollable_source_funcs, sizeof (GPollableSource));
-  g_source_set_name (source, "GPollableSource");
+  g_source_set_static_name (source, "GPollableSource");
   pollable_source = (GPollableSource *)source;
   pollable_source->stream = g_object_ref (pollable_stream);
 
diff --git a/gio/gsimpleasyncresult.c b/gio/gsimpleasyncresult.c
index c6ddd9771..c971bdfcd 100644
--- a/gio/gsimpleasyncresult.c
+++ b/gio/gsimpleasyncresult.c
@@ -842,7 +842,7 @@ g_simple_async_result_complete_in_idle (GSimpleAsyncResult *simple)
   source = g_idle_source_new ();
   g_source_set_priority (source, G_PRIORITY_DEFAULT);
   g_source_set_callback (source, complete_in_idle_cb, simple, g_object_unref);
-  g_source_set_name (source, "[gio] complete_in_idle_cb");
+  g_source_set_static_name (source, "[gio] complete_in_idle_cb");
 
   g_source_attach (source, simple->context);
   g_source_unref (source);
@@ -903,7 +903,7 @@ run_in_thread (GIOSchedulerJob *job,
   source = g_idle_source_new ();
   g_source_set_priority (source, G_PRIORITY_DEFAULT);
   g_source_set_callback (source, complete_in_idle_cb_for_thread, data, NULL);
-  g_source_set_name (source, "[gio] complete_in_idle_cb_for_thread");
+  g_source_set_static_name (source, "[gio] complete_in_idle_cb_for_thread");
 
   g_source_attach (source, simple->context);
   g_source_unref (source);
diff --git a/gio/gsocket.c b/gio/gsocket.c
index a7ba27d0c..d5603c538 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -4114,7 +4114,7 @@ socket_source_new (GSocket      *socket,
   condition |= G_IO_HUP | G_IO_ERR | G_IO_NVAL;
 
   source = g_source_new (&socket_source_funcs, sizeof (GSocketSource));
-  g_source_set_name (source, "GSocket");
+  g_source_set_static_name (source, "GSocket");
   socket_source = (GSocketSource *)source;
 
   socket_source->socket = g_object_ref (socket);
diff --git a/gio/gtask.c b/gio/gtask.c
index b533a18cf..a767e1909 100644
--- a/gio/gtask.c
+++ b/gio/gtask.c
@@ -2177,7 +2177,7 @@ g_task_thread_pool_init (void)
   g_thread_pool_set_sort_function (task_pool, g_task_compare_priority, NULL);
 
   task_pool_manager = g_source_new (&trivial_source_funcs, sizeof (GSource));
-  g_source_set_name (task_pool_manager, "GTask thread pool manager");
+  g_source_set_static_name (task_pool_manager, "GTask thread pool manager");
   g_source_set_callback (task_pool_manager, task_pool_manager_timeout, NULL, NULL);
   g_source_set_ready_time (task_pool_manager, -1);
   g_source_attach (task_pool_manager,
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index 46a41fc41..e0c8f6778 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -1854,7 +1854,7 @@ mtab_file_changed (GFileMonitor      *monitor,
   source = g_idle_source_new ();
   g_source_set_priority (source, G_PRIORITY_DEFAULT);
   g_source_set_callback (source, mtab_file_changed_cb, NULL, NULL);
-  g_source_set_name (source, "[gio] mtab_file_changed_cb");
+  g_source_set_static_name (source, "[gio] mtab_file_changed_cb");
   g_source_attach (source, context);
   g_source_unref (source);
 }
diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c
index 1a30fc84d..92d61fc31 100644
--- a/gio/inotify/inotify-kernel.c
+++ b/gio/inotify/inotify-kernel.c
@@ -381,7 +381,7 @@ ik_source_new (gboolean (* callback) (ik_event_t *event))
   source = g_source_new (&source_funcs, sizeof (InotifyKernelSource));
   iks = (InotifyKernelSource *) source;
 
-  g_source_set_name (source, "inotify kernel source");
+  g_source_set_static_name (source, "inotify kernel source");
 
   iks->unmatched_moves = g_hash_table_new (NULL, NULL);
   iks->fd = inotify_init1 (IN_CLOEXEC);
diff --git a/glib/giounix.c b/glib/giounix.c
index b86d79db7..ad3aba25b 100644
--- a/glib/giounix.c
+++ b/glib/giounix.c
@@ -348,7 +348,7 @@ g_io_unix_create_watch (GIOChannel   *channel,
 
 
   source = g_source_new (&g_io_watch_funcs, sizeof (GIOUnixWatch));
-  g_source_set_name (source, "GIOChannel (Unix)");
+  g_source_set_static_name (source, "GIOChannel (Unix)");
   watch = (GIOUnixWatch *)source;
   
   watch->channel = channel;
diff --git a/glib/giowin32.c b/glib/giowin32.c
index b0b6c3d85..e4c246d38 100644
--- a/glib/giowin32.c
+++ b/glib/giowin32.c
@@ -1170,7 +1170,7 @@ g_io_win32_msg_create_watch (GIOChannel   *channel,
   GSource *source;
 
   source = g_source_new (&g_io_watch_funcs, sizeof (GIOWin32Watch));
-  g_source_set_name (source, "GIOChannel (Win32)");
+  g_source_set_static_name (source, "GIOChannel (Win32)");
   watch = (GIOWin32Watch *)source;
   
   watch->channel = channel;
diff --git a/glib/gmain.c b/glib/gmain.c
index f36da1eea..6cba3bd53 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -5592,7 +5592,7 @@ _g_main_create_unix_signal_watch (int signum)
   unix_signal_source->pending = FALSE;
 
   /* Set a default name on the source, just in case the caller does not. */
-  g_source_set_name (source, signum_to_string (signum));
+  g_source_set_static_name (source, signum_to_string (signum));
 
   G_LOCK (unix_signal_lock);
   ref_unix_signal_handler_unlocked (signum);
@@ -5729,7 +5729,7 @@ g_child_watch_source_new (GPid pid)
   child_watch_source = (GChildWatchSource *)source;
 
   /* Set a default name on the source, just in case the caller does not. */
-  g_source_set_name (source, "GChildWatchSource");
+  g_source_set_static_name (source, "GChildWatchSource");
 
   child_watch_source->pid = pid;
 
@@ -5918,7 +5918,7 @@ g_idle_source_new (void)
   g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
 
   /* Set a default name on the source, just in case the caller does not. */
-  g_source_set_name (source, "GIdleSource");
+  g_source_set_static_name (source, "GIdleSource");
 
   return source;
 }
diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c
index 4ef0e9c7d..ab1317644 100644
--- a/glib/tests/mainloop.c
+++ b/glib/tests/mainloop.c
@@ -78,7 +78,7 @@ test_maincontext_basic (void)
   g_assert_null (g_source_get_name (source));
 
   g_source_set_can_recurse (source, TRUE);
-  g_source_set_name (source, "d");
+  g_source_set_static_name (source, "d");
 
   g_assert_true (g_source_get_can_recurse (source));
   g_assert_cmpstr (g_source_get_name (source), ==, "d");
diff --git a/tests/mainloop-test.c b/tests/mainloop-test.c
index be6024a10..365864d83 100644
--- a/tests/mainloop-test.c
+++ b/tests/mainloop-test.c
@@ -158,13 +158,13 @@ adder_thread (gpointer data)
   addr_data.count = 0;
 
   adder_source = g_io_create_watch (channels[0], G_IO_IN | G_IO_HUP);
-  g_source_set_name (adder_source, "Adder I/O");
+  g_source_set_static_name (adder_source, "Adder I/O");
   g_source_set_callback (adder_source, (GSourceFunc)adder_callback, &addr_data, NULL);
   g_source_attach (adder_source, context);
   g_source_unref (adder_source);
 
   timeout_source = g_timeout_source_new (10);
-  g_source_set_name (timeout_source, "Adder timeout");
+  g_source_set_static_name (timeout_source, "Adder timeout");
   g_source_set_callback (timeout_source, (GSourceFunc)timeout_callback, &addr_data, NULL);
   g_source_set_priority (timeout_source, G_PRIORITY_HIGH);
   g_source_attach (timeout_source, context);
@@ -335,7 +335,7 @@ static void
 create_crawler (void)
 {
   GSource *source = g_timeout_source_new (g_random_int_range (0, CRAWLER_TIMEOUT_RANGE));
-  g_source_set_name (source, "Crawler timeout");
+  g_source_set_static_name (source, "Crawler timeout");
   g_source_set_callback (source, (GSourceFunc)crawler_callback, source, NULL);
 
   G_LOCK (crawler_array_lock);
@@ -389,7 +389,7 @@ recurser_start (gpointer data)
     {
       context = context_array->pdata[g_random_int_range (0, context_array->len)];
       source = g_idle_source_new ();
-      g_source_set_name (source, "Recursing idle source");
+      g_source_set_static_name (source, "Recursing idle source");
       g_source_set_callback (source, recurser_idle, context, NULL);
       g_source_attach (source, context);
       g_source_unref (source);


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