mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
tracers: leaks: delay type name lookup
Micro optimisation: Store the quark of the type name when tracking objects and only do the quark to string conversion (hashtable lookup) later when we actually need the string. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2846>
This commit is contained in:
parent
6212831f04
commit
703f05b6f9
1 changed files with 7 additions and 5 deletions
|
@ -318,7 +318,7 @@ should_handle_object_type (GstLeaksTracer * self, GType object_type)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gpointer object;
|
gpointer object;
|
||||||
const gchar *type_name;
|
GQuark type_qname;
|
||||||
} ObjectLog;
|
} ObjectLog;
|
||||||
|
|
||||||
static ObjectLog *
|
static ObjectLog *
|
||||||
|
@ -330,10 +330,10 @@ object_log_new (gpointer obj, ObjectKind kind)
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case GOBJECT:
|
case GOBJECT:
|
||||||
o->type_name = G_OBJECT_TYPE_NAME (obj);
|
o->type_qname = g_type_qname (G_OBJECT_TYPE (obj));
|
||||||
break;
|
break;
|
||||||
case MINI_OBJECT:
|
case MINI_OBJECT:
|
||||||
o->type_name = g_type_name (GST_MINI_OBJECT_TYPE (obj));
|
o->type_qname = g_type_qname (GST_MINI_OBJECT_TYPE (obj));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
@ -1058,16 +1058,18 @@ process_checkpoint (GstTracerRecord * record, const gchar * record_type,
|
||||||
while (g_hash_table_iter_next (&iter, &o, NULL)) {
|
while (g_hash_table_iter_next (&iter, &o, NULL)) {
|
||||||
ObjectLog *obj = o;
|
ObjectLog *obj = o;
|
||||||
|
|
||||||
|
const gchar *type_name = g_quark_to_string (obj->type_qname);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
/* log to the debug log */
|
/* log to the debug log */
|
||||||
gst_tracer_record_log (record, obj->type_name, obj->object);
|
gst_tracer_record_log (record, type_name, obj->object);
|
||||||
} else {
|
} else {
|
||||||
GValue s_value = G_VALUE_INIT;
|
GValue s_value = G_VALUE_INIT;
|
||||||
GValue addr_value = G_VALUE_INIT;
|
GValue addr_value = G_VALUE_INIT;
|
||||||
gchar *address = g_strdup_printf ("%p", obj->object);
|
gchar *address = g_strdup_printf ("%p", obj->object);
|
||||||
GstStructure *s = gst_structure_new_empty (record_type);
|
GstStructure *s = gst_structure_new_empty (record_type);
|
||||||
/* copy type_name because it's owned by @obj */
|
/* copy type_name because it's owned by @obj */
|
||||||
gst_structure_set (s, "type-name", G_TYPE_STRING, obj->type_name, NULL);
|
gst_structure_set (s, "type-name", G_TYPE_STRING, type_name, NULL);
|
||||||
/* avoid copy of @address */
|
/* avoid copy of @address */
|
||||||
g_value_init (&addr_value, G_TYPE_STRING);
|
g_value_init (&addr_value, G_TYPE_STRING);
|
||||||
g_value_take_string (&addr_value, address);
|
g_value_take_string (&addr_value, address);
|
||||||
|
|
Loading…
Reference in a new issue