Port internal uses to use g_source_set_static_name()

This should reduce allocations.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-07-26 10:53:02 +01:00
parent 302346d4d3
commit 8e963e0e31
22 changed files with 40 additions and 40 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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");

View File

@ -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);