[glib] g_format_size: avoid silly GString use
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] g_format_size: avoid silly GString use
- Date: Tue, 26 Jul 2011 11:30:40 +0000 (UTC)
commit 01744c2d69fb11a8dfde62666540da91adafd6a8
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Jul 26 13:26:10 2011 +0200
g_format_size: avoid silly GString use
We were using a GString for the purpose of doing a single printf(). Do
g_strdup_printf() instead.
glib/gfileutils.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 75ba044..0101255 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1935,16 +1935,15 @@ g_format_size_full (guint64 size,
* all platforms.
*/
const gchar *translated_format;
- GString *formatted_number;
+ gchar *formatted_number;
/* Translators: the %s in "%s bytes" will always be replaced by a number. */
translated_format = g_dngettext(GETTEXT_PACKAGE, "%s byte", "%s bytes", plural_form);
- formatted_number = g_string_new (NULL);
- g_string_printf (formatted_number, "%'"G_GUINT64_FORMAT, size);
+ formatted_number = g_strdup_printf ("%'"G_GUINT64_FORMAT, size);
g_string_append (string, " (");
- g_string_append_printf (string, translated_format, formatted_number->str);
- g_string_free (formatted_number, TRUE);
+ g_string_append_printf (string, translated_format, formatted_number);
+ g_free (formatted_number);
g_string_append (string, ")");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]