gst/gststructure.c: add gst_structure_id_empty_new_with_size to allow preallocating value array sizes. Use this in gs...

Original commit message from CVS:
* gst/gststructure.c: (gst_structure_id_empty_new_with_size),
(gst_structure_id_empty_new), (gst_structure_empty_new),
(gst_structure_copy):
add gst_structure_id_empty_new_with_size to allow preallocating
value array sizes. Use this in gst_structure_copy to get rid of
reallocs.
don't do quark=>string=>quark when copying structures
This commit is contained in:
Benjamin Otte 2004-08-04 12:39:12 +00:00
parent e226919ba2
commit ce7ad83f64
2 changed files with 29 additions and 18 deletions

View file

@ -1,3 +1,13 @@
2004-08-04 Benjamin Otte <otte@gnome.org>
* gst/gststructure.c: (gst_structure_id_empty_new_with_size),
(gst_structure_id_empty_new), (gst_structure_empty_new),
(gst_structure_copy):
add gst_structure_id_empty_new_with_size to allow preallocating
value array sizes. Use this in gst_structure_copy to get rid of
reallocs.
don't do quark=>string=>quark when copying structures
2004-08-03 Steve Lhomme <steve.lhomme@free.fr> 2004-08-03 Steve Lhomme <steve.lhomme@free.fr>
* docs/manual/win32.xml: * docs/manual/win32.xml:

View file

@ -71,6 +71,20 @@ gst_structure_get_type (void)
return gst_structure_type; return gst_structure_type;
} }
GstStructure *
gst_structure_id_empty_new_with_size (GQuark quark, guint prealloc)
{
GstStructure *structure;
structure = g_new0 (GstStructure, 1);
structure->type = gst_structure_get_type ();
structure->name = quark;
structure->fields =
g_array_sized_new (FALSE, TRUE, sizeof (GstStructureField), prealloc);
return structure;
}
/** /**
* gst_structure_id_empty_new: * gst_structure_id_empty_new:
* @quark: name of new structure * @quark: name of new structure
@ -82,16 +96,9 @@ gst_structure_get_type (void)
GstStructure * GstStructure *
gst_structure_id_empty_new (GQuark quark) gst_structure_id_empty_new (GQuark quark)
{ {
GstStructure *structure;
g_return_val_if_fail (quark != 0, NULL); g_return_val_if_fail (quark != 0, NULL);
structure = g_new0 (GstStructure, 1); return gst_structure_id_empty_new_with_size (quark, 0);
structure->type = gst_structure_get_type ();
structure->name = quark;
structure->fields = g_array_new (FALSE, TRUE, sizeof (GstStructureField));
return structure;
} }
/** /**
@ -105,16 +112,9 @@ gst_structure_id_empty_new (GQuark quark)
GstStructure * GstStructure *
gst_structure_empty_new (const gchar * name) gst_structure_empty_new (const gchar * name)
{ {
GstStructure *structure;
g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name != NULL, NULL);
structure = g_new0 (GstStructure, 1); return gst_structure_id_empty_new_with_size (g_quark_from_string (name), 0);
structure->type = gst_structure_get_type ();
structure->name = g_quark_from_string (name);
structure->fields = g_array_new (FALSE, TRUE, sizeof (GstStructureField));
return structure;
} }
/** /**
@ -190,8 +190,9 @@ gst_structure_copy (const GstStructure * structure)
g_return_val_if_fail (structure != NULL, NULL); g_return_val_if_fail (structure != NULL, NULL);
new_structure = gst_structure_empty_new (g_quark_to_string (structure->name)); new_structure =
new_structure->name = structure->name; gst_structure_id_empty_new_with_size (structure->name,
structure->fields->len);
for (i = 0; i < structure->fields->len; i++) { for (i = 0; i < structure->fields->len; i++) {
GstStructureField new_field = { 0 }; GstStructureField new_field = { 0 };