More string interning

This commit is contained in:
Matthias Clasen 2005-08-31 17:56:49 +00:00
parent 3a151501cc
commit 63b1b0c187
4 changed files with 34 additions and 29 deletions

View File

@ -1,5 +1,10 @@
2005-08-31 Matthias Clasen <mclasen@redhat.com>
* gboxed.c:
* gparamspecs.c:
* gtype.c (g_type_init_with_debug_flags): Intern type name
before registering the types.
* gtype.h (G_DEFINE_TYPE_EXTENDED): Intern type name
before registering the type.

View File

@ -150,7 +150,7 @@ g_closure_get_type (void)
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GClosure",
type_id = g_boxed_type_register_static (g_intern_static_string ("GClosure"),
(GBoxedCopyFunc) g_closure_ref,
(GBoxedFreeFunc) g_closure_unref);
return type_id;
@ -162,7 +162,7 @@ g_value_get_type (void)
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GValue",
type_id = g_boxed_type_register_static (g_intern_static_string ("GValue"),
value_copy,
value_free);
return type_id;
@ -174,7 +174,7 @@ g_value_array_get_type (void)
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GValueArray",
type_id = g_boxed_type_register_static (g_intern_static_string ("GValueArray"),
(GBoxedCopyFunc) g_value_array_copy,
(GBoxedFreeFunc) g_value_array_free);
return type_id;
@ -186,7 +186,7 @@ g_date_get_type (void)
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GDate",
type_id = g_boxed_type_register_static (g_intern_static_string ("GDate"),
(GBoxedCopyFunc) gdate_copy,
(GBoxedFreeFunc) g_date_free);
return type_id;
@ -198,7 +198,7 @@ g_strv_get_type (void)
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GStrv",
type_id = g_boxed_type_register_static (g_intern_static_string ("GStrv"),
(GBoxedCopyFunc) g_strdupv,
(GBoxedFreeFunc) g_strfreev);
return type_id;
@ -210,7 +210,7 @@ g_gstring_get_type (void)
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GString", /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
type_id = g_boxed_type_register_static (g_intern_static_string ("GString"), /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
gstring_copy,
gstring_free);
return type_id;

View File

@ -1042,7 +1042,7 @@ g_param_spec_types_init (void)
param_char_validate, /* value_validate */
param_int_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamChar", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_CHAR);
}
@ -1060,7 +1060,7 @@ g_param_spec_types_init (void)
param_uchar_validate, /* value_validate */
param_uint_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamUChar", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UCHAR);
}
@ -1078,7 +1078,7 @@ g_param_spec_types_init (void)
param_boolean_validate, /* value_validate */
param_int_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamBoolean", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_BOOLEAN);
}
@ -1096,7 +1096,7 @@ g_param_spec_types_init (void)
param_int_validate, /* value_validate */
param_int_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamInt", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_INT);
}
@ -1114,7 +1114,7 @@ g_param_spec_types_init (void)
param_uint_validate, /* value_validate */
param_uint_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamUInt", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UINT);
}
@ -1132,7 +1132,7 @@ g_param_spec_types_init (void)
param_long_validate, /* value_validate */
param_long_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamLong", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_LONG);
}
@ -1150,7 +1150,7 @@ g_param_spec_types_init (void)
param_ulong_validate, /* value_validate */
param_ulong_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamULong", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_ULONG);
}
@ -1168,7 +1168,7 @@ g_param_spec_types_init (void)
param_int64_validate, /* value_validate */
param_int64_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamInt64", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_INT64);
}
@ -1186,7 +1186,7 @@ g_param_spec_types_init (void)
param_uint64_validate, /* value_validate */
param_uint64_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamUInt64", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UINT64);
}
@ -1204,7 +1204,7 @@ g_param_spec_types_init (void)
param_unichar_validate, /* value_validate */
param_unichar_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamUnichar", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UNICHAR);
}
@ -1222,7 +1222,7 @@ g_param_spec_types_init (void)
param_enum_validate, /* value_validate */
param_long_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamEnum", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_ENUM);
}
@ -1240,7 +1240,7 @@ g_param_spec_types_init (void)
param_flags_validate, /* value_validate */
param_ulong_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamFlags", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_FLAGS);
}
@ -1258,7 +1258,7 @@ g_param_spec_types_init (void)
param_float_validate, /* value_validate */
param_float_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamFloat", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_FLOAT);
}
@ -1276,7 +1276,7 @@ g_param_spec_types_init (void)
param_double_validate, /* value_validate */
param_double_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamDouble", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_DOUBLE);
}
@ -1294,7 +1294,7 @@ g_param_spec_types_init (void)
param_string_validate, /* value_validate */
param_string_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamString", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_STRING);
}
@ -1312,7 +1312,7 @@ g_param_spec_types_init (void)
param_param_validate, /* value_validate */
param_pointer_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamParam", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_PARAM);
}
@ -1330,7 +1330,7 @@ g_param_spec_types_init (void)
param_boxed_validate, /* value_validate */
param_boxed_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamBoxed", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_BOXED);
}
@ -1348,7 +1348,7 @@ g_param_spec_types_init (void)
param_pointer_validate, /* value_validate */
param_pointer_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamPointer", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_POINTER);
}
@ -1367,7 +1367,7 @@ g_param_spec_types_init (void)
param_value_array_values_cmp, /* values_cmp */
};
pspec_info.value_type = G_TYPE_VALUE_ARRAY;
type = g_param_type_register_static ("GParamValueArray", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_VALUE_ARRAY);
}
@ -1385,7 +1385,7 @@ g_param_spec_types_init (void)
param_object_validate, /* value_validate */
param_object_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamObject", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_OBJECT);
}
@ -1403,7 +1403,7 @@ g_param_spec_types_init (void)
param_override_validate, /* value_validate */
param_override_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamOverride", &pspec_info);
type = g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info);
*spec_types++ = type;
g_assert (type == G_TYPE_PARAM_OVERRIDE);
}

View File

@ -3426,14 +3426,14 @@ g_type_init_with_debug_flags (GTypeDebugFlags debug_flags)
/* void type G_TYPE_NONE
*/
node = type_node_fundamental_new_W (G_TYPE_NONE, "void", 0);
node = type_node_fundamental_new_W (G_TYPE_NONE, g_intern_static_string ("void"), 0);
type = NODE_TYPE (node);
g_assert (type == G_TYPE_NONE);
/* interface fundamental type G_TYPE_INTERFACE (!classed)
*/
memset (&info, 0, sizeof (info));
node = type_node_fundamental_new_W (G_TYPE_INTERFACE, "GInterface", G_TYPE_FLAG_DERIVABLE);
node = type_node_fundamental_new_W (G_TYPE_INTERFACE, g_intern_static_string ("GInterface"), G_TYPE_FLAG_DERIVABLE);
type = NODE_TYPE (node);
type_data_make_W (node, &info, NULL);
g_assert (type == G_TYPE_INTERFACE);