gst/: Put more strings into the GLib quark table. No need to keep a hundred-something copies of identical version str...

Original commit message from CVS:
* gst/gstplugin.c:
* gst/gstplugin.h:
* gst/gstregistrybinary.c:
* gst/gstregistryxml.c:
Put more strings into the GLib quark table. No need to keep
a hundred-something copies of identical version strings,
license strings, package name strings and package origin
strings around.
This commit is contained in:
Tim-Philipp Müller 2007-10-09 14:18:39 +00:00
parent c3a2e0699f
commit a90dc9f01a
5 changed files with 36 additions and 31 deletions

View file

@ -1,3 +1,14 @@
2007-10-09 Tim-Philipp Müller <tim at centricular dot net>
* gst/gstplugin.c:
* gst/gstplugin.h:
* gst/gstregistrybinary.c:
* gst/gstregistryxml.c:
Put more strings into the GLib quark table. No need to keep
a hundred-something copies of identical version strings,
license strings, package name strings and package origin
strings around.
2007-10-09 Tim-Philipp Müller <tim at centricular dot net> 2007-10-09 Tim-Philipp Müller <tim at centricular dot net>
* docs/manual/advanced-dataaccess.xml: * docs/manual/advanced-dataaccess.xml:

View file

@ -495,28 +495,22 @@ gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src)
{ {
dest->major_version = src->major_version; dest->major_version = src->major_version;
dest->minor_version = src->minor_version; dest->minor_version = src->minor_version;
dest->name = g_strdup (src->name); dest->name = g_intern_string (src->name);
/* maybe intern the description too, just for convenience? */
dest->description = g_strdup (src->description); dest->description = g_strdup (src->description);
dest->plugin_init = src->plugin_init; dest->plugin_init = src->plugin_init;
dest->version = g_strdup (src->version); dest->version = g_intern_string (src->version);
dest->license = g_strdup (src->license); dest->license = g_intern_string (src->license);
dest->source = g_strdup (src->source); dest->source = g_intern_string (src->source);
dest->package = g_strdup (src->package); dest->package = g_intern_string (src->package);
dest->origin = g_strdup (src->origin); dest->origin = g_intern_string (src->origin);
} }
/* unused */ /* unused */
static void static void
gst_plugin_desc_free (GstPluginDesc * desc) gst_plugin_desc_free (GstPluginDesc * desc)
{ {
g_free (desc->name);
g_free (desc->description); g_free (desc->description);
g_free (desc->version);
g_free (desc->license);
g_free (desc->source);
g_free (desc->package);
g_free (desc->origin);
memset (desc, 0, sizeof (GstPluginDesc)); memset (desc, 0, sizeof (GstPluginDesc));
} }

View file

@ -110,14 +110,14 @@ typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
struct _GstPluginDesc { struct _GstPluginDesc {
gint major_version; gint major_version;
gint minor_version; gint minor_version;
gchar *name; const gchar *name;
gchar *description; gchar *description;
GstPluginInitFunc plugin_init; GstPluginInitFunc plugin_init;
gchar *version; const gchar *version;
gchar *license; const gchar *license;
gchar *source; const gchar *source;
gchar *package; const gchar *package;
gchar *origin; const gchar *origin;
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
}; };

View file

@ -823,14 +823,14 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in)
plugin->file_size = pe->file_size; plugin->file_size = pe->file_size;
/* unpack plugin element strings */ /* unpack plugin element strings */
unpack_string (*in, plugin->desc.name); unpack_const_string (*in, plugin->desc.name);
unpack_string (*in, plugin->desc.description); unpack_string (*in, plugin->desc.description);
unpack_string (*in, plugin->filename); unpack_string (*in, plugin->filename);
unpack_string (*in, plugin->desc.version); unpack_const_string (*in, plugin->desc.version);
unpack_string (*in, plugin->desc.license); unpack_const_string (*in, plugin->desc.license);
unpack_string (*in, plugin->desc.source); unpack_const_string (*in, plugin->desc.source);
unpack_string (*in, plugin->desc.package); unpack_const_string (*in, plugin->desc.package);
unpack_string (*in, plugin->desc.origin); unpack_const_string (*in, plugin->desc.origin);
GST_LOG ("read strings for '%s'", plugin->desc.name); GST_LOG ("read strings for '%s'", plugin->desc.name);
plugin->basename = g_path_get_basename (plugin->filename); plugin->basename = g_path_get_basename (plugin->filename);

View file

@ -404,7 +404,7 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list)
if (g_str_equal (tag, "name")) { if (g_str_equal (tag, "name")) {
int ret; int ret;
ret = read_string (reader, &plugin->desc.name, FALSE); ret = read_const_interned_string (reader, &plugin->desc.name, FALSE);
GST_LOG ("name ret=%d, name=%s", ret, plugin->desc.name); GST_LOG ("name ret=%d, name=%s", ret, plugin->desc.name);
if (!ret) if (!ret)
break; break;
@ -422,31 +422,31 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list)
GST_LOG ("filename %s", plugin->filename); GST_LOG ("filename %s", plugin->filename);
plugin->basename = g_path_get_basename (plugin->filename); plugin->basename = g_path_get_basename (plugin->filename);
} else if (g_str_equal (tag, "version")) { } else if (g_str_equal (tag, "version")) {
if (!read_string (reader, &plugin->desc.version, TRUE)) { if (!read_const_interned_string (reader, &plugin->desc.version, TRUE)) {
GST_WARNING ("version field was invalid in registry"); GST_WARNING ("version field was invalid in registry");
break; break;
} }
GST_LOG ("version %s", plugin->desc.version); GST_LOG ("version %s", plugin->desc.version);
} else if (g_str_equal (tag, "license")) { } else if (g_str_equal (tag, "license")) {
if (!read_string (reader, &plugin->desc.license, TRUE)) { if (!read_const_interned_string (reader, &plugin->desc.license, TRUE)) {
GST_WARNING ("license field was invalid in registry"); GST_WARNING ("license field was invalid in registry");
break; break;
} }
GST_LOG ("license %s", plugin->desc.license); GST_LOG ("license %s", plugin->desc.license);
} else if (g_str_equal (tag, "source")) { } else if (g_str_equal (tag, "source")) {
if (!read_string (reader, &plugin->desc.source, TRUE)) { if (!read_const_interned_string (reader, &plugin->desc.source, TRUE)) {
GST_WARNING ("source field was invalid in registry"); GST_WARNING ("source field was invalid in registry");
break; break;
} }
GST_LOG ("source %s", plugin->desc.source); GST_LOG ("source %s", plugin->desc.source);
} else if (g_str_equal (tag, "package")) { } else if (g_str_equal (tag, "package")) {
if (!read_string (reader, &plugin->desc.package, TRUE)) { if (!read_const_interned_string (reader, &plugin->desc.package, TRUE)) {
GST_WARNING ("package field was invalid in registry"); GST_WARNING ("package field was invalid in registry");
break; break;
} }
GST_LOG ("package %s", plugin->desc.package); GST_LOG ("package %s", plugin->desc.package);
} else if (g_str_equal (tag, "origin")) { } else if (g_str_equal (tag, "origin")) {
if (!read_string (reader, &plugin->desc.origin, TRUE)) { if (!read_const_interned_string (reader, &plugin->desc.origin, TRUE)) {
GST_WARNING ("failed to read origin"); GST_WARNING ("failed to read origin");
break; break;
} }