diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2007-12-28 14:15:53 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2007-12-28 14:15:53 +0000 |
commit | 5cb869bfdf5c5c387a706b54ec22867437f29f4d (patch) | |
tree | 6520a09fea0c72efa28a23a44fdbcfa47e582dc1 | |
parent | dd739adfa72066d51c1b9445b241e0e1c566c1c0 (diff) | |
download | gstreamer-5cb869bfdf5c5c387a706b54ec22867437f29f4d.tar.gz |
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.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | gst/gstcaps.c | 2 | ||||
-rw-r--r-- | gst/gstinfo.c | 11 | ||||
-rw-r--r-- | gst/gstparse.c | 2 | ||||
-rw-r--r-- | gst/gstutils.c | 4 | ||||
-rw-r--r-- | gst/gstvalue.c | 12 |
6 files changed, 26 insertions, 15 deletions
@@ -1,5 +1,15 @@ 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> + * tests/check/generic/sinks.c: (async_done_func), (async_done_eos_func): Fix leak in unit test (bus sync handler must unref the message diff --git a/gst/gstcaps.c b/gst/gstcaps.c index a090765a84..ac3545dcd6 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1799,7 +1799,7 @@ gst_caps_to_string (const GstCaps * caps) if (i > 0) { /* ';' is now added by gst_structure_to_string */ - g_string_append (s, " "); + g_string_append_c (s, ' '); } structure = gst_caps_get_structure (caps, i); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 0f1c05658d..7dbd1af4e4 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -573,15 +573,14 @@ gchar * gst_debug_construct_term_color (guint colorinfo) { GString *color; - gchar *ret; color = g_string_new ("\033[00"); if (colorinfo & GST_DEBUG_BOLD) { - g_string_append (color, ";01"); + g_string_append_len (color, ";01", 3); } if (colorinfo & GST_DEBUG_UNDERLINE) { - g_string_append (color, ";04"); + g_string_append_len (color, ";04", 3); } if (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", (colorinfo & GST_DEBUG_BG_MASK) >> 4); } - g_string_append (color, "m"); + g_string_append_c (color, 'm'); - ret = color->str; - g_string_free (color, FALSE); - return ret; + return g_string_free (color, FALSE); } /** diff --git a/gst/gstparse.c b/gst/gstparse.c index 041f68ad35..ba6a6f1fbe 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -112,7 +112,7 @@ gst_parse_launchv (const gchar ** argv, GError ** error) tmp = _gst_parse_escape (arg); g_string_append (str, tmp); g_free (tmp); - g_string_append (str, " "); + g_string_append_c (str, ' '); argvp++; } diff --git a/gst/gstutils.c b/gst/gstutils.c index d21adf021e..1b446f919c 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -57,9 +57,9 @@ gst_util_dump_mem (const guchar * mem, guint size) i = j = 0; while (i < size) { if (g_ascii_isprint (mem[i])) - g_string_append_printf (chars, "%c", mem[i]); + g_string_append_c (chars, mem[i]); else - g_string_append_printf (chars, "."); + g_string_append_c (chars, '.'); g_string_append_printf (string, "%02x ", mem[i]); diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 6e4410864a..1314c828a8 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -97,14 +97,16 @@ gst_value_serialize_any_list (const GValue * value, const gchar * begin, GValue *v; 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++) { v = &g_array_index (array, GValue, i); s_val = gst_value_serialize (v); g_string_append (s, s_val); g_free (s_val); if (i < array->len - 1) { - g_string_append (s, ", "); + g_string_append_len (s, ", ", 2); } } 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; - 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++) { list_value = &g_array_index (array, GValue, i); if (i != 0) { - g_string_append (s, ", "); + g_string_append_len (s, ", ", 2); } list_s = g_strdup_value_contents (list_value); g_string_append (s, list_s); |