mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
gst/: Bunch of gratuitous nano-optimisations.
Original commit message from CVS: * gst/gstcaps.c: (gst_caps_to_string): * gst/gstinfo.c: (gst_debug_construct_term_color): * gst/gstparse.c: (gst_parse_launchv): * gst/gstutils.c: (gst_util_dump_mem): * gst/gstvalue.c: (gst_value_serialize_any_list), (gst_value_transform_any_list_string): Bunch of gratuitous nano-optimisations.
This commit is contained in:
parent
dd739adfa7
commit
5cb869bfdf
6 changed files with 26 additions and 15 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2007-12-28 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* gst/gstcaps.c: (gst_caps_to_string):
|
||||||
|
* gst/gstinfo.c: (gst_debug_construct_term_color):
|
||||||
|
* gst/gstparse.c: (gst_parse_launchv):
|
||||||
|
* gst/gstutils.c: (gst_util_dump_mem):
|
||||||
|
* gst/gstvalue.c: (gst_value_serialize_any_list),
|
||||||
|
(gst_value_transform_any_list_string):
|
||||||
|
Bunch of gratuitous nano-optimisations.
|
||||||
|
|
||||||
2007-12-28 Tim-Philipp Müller <tim at centricular dot net>
|
2007-12-28 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* tests/check/generic/sinks.c: (async_done_func),
|
* tests/check/generic/sinks.c: (async_done_func),
|
||||||
|
|
|
@ -1799,7 +1799,7 @@ gst_caps_to_string (const GstCaps * caps)
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
/* ';' is now added by gst_structure_to_string */
|
/* ';' is now added by gst_structure_to_string */
|
||||||
g_string_append (s, " ");
|
g_string_append_c (s, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, i);
|
structure = gst_caps_get_structure (caps, i);
|
||||||
|
|
|
@ -573,15 +573,14 @@ gchar *
|
||||||
gst_debug_construct_term_color (guint colorinfo)
|
gst_debug_construct_term_color (guint colorinfo)
|
||||||
{
|
{
|
||||||
GString *color;
|
GString *color;
|
||||||
gchar *ret;
|
|
||||||
|
|
||||||
color = g_string_new ("\033[00");
|
color = g_string_new ("\033[00");
|
||||||
|
|
||||||
if (colorinfo & GST_DEBUG_BOLD) {
|
if (colorinfo & GST_DEBUG_BOLD) {
|
||||||
g_string_append (color, ";01");
|
g_string_append_len (color, ";01", 3);
|
||||||
}
|
}
|
||||||
if (colorinfo & GST_DEBUG_UNDERLINE) {
|
if (colorinfo & GST_DEBUG_UNDERLINE) {
|
||||||
g_string_append (color, ";04");
|
g_string_append_len (color, ";04", 3);
|
||||||
}
|
}
|
||||||
if (colorinfo & GST_DEBUG_FG_MASK) {
|
if (colorinfo & GST_DEBUG_FG_MASK) {
|
||||||
g_string_append_printf (color, ";3%1d", colorinfo & GST_DEBUG_FG_MASK);
|
g_string_append_printf (color, ";3%1d", colorinfo & GST_DEBUG_FG_MASK);
|
||||||
|
@ -590,11 +589,9 @@ gst_debug_construct_term_color (guint colorinfo)
|
||||||
g_string_append_printf (color, ";4%1d",
|
g_string_append_printf (color, ";4%1d",
|
||||||
(colorinfo & GST_DEBUG_BG_MASK) >> 4);
|
(colorinfo & GST_DEBUG_BG_MASK) >> 4);
|
||||||
}
|
}
|
||||||
g_string_append (color, "m");
|
g_string_append_c (color, 'm');
|
||||||
|
|
||||||
ret = color->str;
|
return g_string_free (color, FALSE);
|
||||||
g_string_free (color, FALSE);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -112,7 +112,7 @@ gst_parse_launchv (const gchar ** argv, GError ** error)
|
||||||
tmp = _gst_parse_escape (arg);
|
tmp = _gst_parse_escape (arg);
|
||||||
g_string_append (str, tmp);
|
g_string_append (str, tmp);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
g_string_append (str, " ");
|
g_string_append_c (str, ' ');
|
||||||
argvp++;
|
argvp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,9 @@ gst_util_dump_mem (const guchar * mem, guint size)
|
||||||
i = j = 0;
|
i = j = 0;
|
||||||
while (i < size) {
|
while (i < size) {
|
||||||
if (g_ascii_isprint (mem[i]))
|
if (g_ascii_isprint (mem[i]))
|
||||||
g_string_append_printf (chars, "%c", mem[i]);
|
g_string_append_c (chars, mem[i]);
|
||||||
else
|
else
|
||||||
g_string_append_printf (chars, ".");
|
g_string_append_c (chars, '.');
|
||||||
|
|
||||||
g_string_append_printf (string, "%02x ", mem[i]);
|
g_string_append_printf (string, "%02x ", mem[i]);
|
||||||
|
|
||||||
|
|
|
@ -97,14 +97,16 @@ gst_value_serialize_any_list (const GValue * value, const gchar * begin,
|
||||||
GValue *v;
|
GValue *v;
|
||||||
gchar *s_val;
|
gchar *s_val;
|
||||||
|
|
||||||
s = g_string_new (begin);
|
/* estimate minimum string length to minimise re-allocs in GString */
|
||||||
|
s = g_string_sized_new (2 + (6 * array->len) + 2);
|
||||||
|
g_string_append (s, begin);
|
||||||
for (i = 0; i < array->len; i++) {
|
for (i = 0; i < array->len; i++) {
|
||||||
v = &g_array_index (array, GValue, i);
|
v = &g_array_index (array, GValue, i);
|
||||||
s_val = gst_value_serialize (v);
|
s_val = gst_value_serialize (v);
|
||||||
g_string_append (s, s_val);
|
g_string_append (s, s_val);
|
||||||
g_free (s_val);
|
g_free (s_val);
|
||||||
if (i < array->len - 1) {
|
if (i < array->len - 1) {
|
||||||
g_string_append (s, ", ");
|
g_string_append_len (s, ", ", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_string_append (s, end);
|
g_string_append (s, end);
|
||||||
|
@ -123,12 +125,14 @@ gst_value_transform_any_list_string (const GValue * src_value,
|
||||||
|
|
||||||
array = src_value->data[0].v_pointer;
|
array = src_value->data[0].v_pointer;
|
||||||
|
|
||||||
s = g_string_new (begin);
|
/* estimate minimum string length to minimise re-allocs in GString */
|
||||||
|
s = g_string_sized_new (2 + (10 * array->len) + 2);
|
||||||
|
g_string_append (s, begin);
|
||||||
for (i = 0; i < array->len; i++) {
|
for (i = 0; i < array->len; i++) {
|
||||||
list_value = &g_array_index (array, GValue, i);
|
list_value = &g_array_index (array, GValue, i);
|
||||||
|
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
g_string_append (s, ", ");
|
g_string_append_len (s, ", ", 2);
|
||||||
}
|
}
|
||||||
list_s = g_strdup_value_contents (list_value);
|
list_s = g_strdup_value_contents (list_value);
|
||||||
g_string_append (s, list_s);
|
g_string_append (s, list_s);
|
||||||
|
|
Loading…
Reference in a new issue