From: <tp...@ke...> - 2007-12-28 14:16:07
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: tpm Date: Fri Dec 28 2007 14:16:08 UTC Log message: * 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. Modified files: . : ChangeLog gst : gstcaps.c gstinfo.c gstparse.c gstutils.c gstvalue.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.3598&r2=1.3599 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstcaps.c.diff?r1=1.181&r2=1.182 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstinfo.c.diff?r1=1.143&r2=1.144 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstparse.c.diff?r1=1.76&r2=1.77 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstutils.c.diff?r1=1.168&r2=1.169 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstvalue.c.diff?r1=1.138&r2=1.139 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.3598 retrieving revision 1.3599 diff -u -d -r1.3598 -r1.3599 --- ChangeLog 28 Dec 2007 13:57:03 -0000 1.3598 +++ ChangeLog 28 Dec 2007 14:15:51 -0000 1.3599 @@ -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 Index: gstcaps.c RCS file: /cvs/gstreamer/gstreamer/gst/gstcaps.c,v retrieving revision 1.181 retrieving revision 1.182 diff -u -d -r1.181 -r1.182 --- gstcaps.c 22 Oct 2007 08:53:25 -0000 1.181 +++ gstcaps.c 28 Dec 2007 14:15:53 -0000 1.182 @@ -1799,7 +1799,7 @@ 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); Index: gstinfo.c RCS file: /cvs/gstreamer/gstreamer/gst/gstinfo.c,v retrieving revision 1.143 retrieving revision 1.144 diff -u -d -r1.143 -r1.144 --- gstinfo.c 12 Dec 2007 23:19:59 -0000 1.143 +++ gstinfo.c 28 Dec 2007 14:15:53 -0000 1.144 @@ -573,15 +573,14 @@ 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 @@ 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); } /** Index: gstparse.c RCS file: /cvs/gstreamer/gstreamer/gst/gstparse.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- gstparse.c 9 May 2007 16:32:07 -0000 1.76 +++ gstparse.c 28 Dec 2007 14:15:53 -0000 1.77 @@ -112,7 +112,7 @@ tmp = _gst_parse_escape (arg); g_string_append (str, tmp); g_free (tmp); - g_string_append (str, " "); + g_string_append_c (str, ' '); argvp++; Index: gstutils.c RCS file: /cvs/gstreamer/gstreamer/gst/gstutils.c,v retrieving revision 1.168 retrieving revision 1.169 diff -u -d -r1.168 -r1.169 --- gstutils.c 13 Dec 2007 13:59:04 -0000 1.168 +++ gstutils.c 28 Dec 2007 14:15:53 -0000 1.169 @@ -57,9 +57,9 @@ 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]); Index: gstvalue.c RCS file: /cvs/gstreamer/gstreamer/gst/gstvalue.c,v retrieving revision 1.138 retrieving revision 1.139 diff -u -d -r1.138 -r1.139 --- gstvalue.c 12 Dec 2007 14:04:14 -0000 1.138 +++ gstvalue.c 28 Dec 2007 14:15:53 -0000 1.139 @@ -97,14 +97,16 @@ 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 @@ array = src_value->data[0].v_pointer; + s = g_string_sized_new (2 + (10 * array->len) + 2); list_value = &g_array_index (array, GValue, i); if (i != 0) { list_s = g_strdup_value_contents (list_value); g_string_append (s, list_s); |