From d5d7b4781e116bd8dcaab28ad7d1db8f57d21621 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 30 Mar 2020 12:15:05 +0200 Subject: [PATCH] shared: pre-allocate GString with 16 bytes for _nm_utils_enum_to_str_full() In the next commit, GString will be replaced by NMStrBuf. Then, we will pre-allocate a string buffer with 16 bytes, and measure the performance difference. To have it comparable, adjust the pre-allocation size also with GString. --- shared/nm-glib-aux/nm-enum-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/nm-glib-aux/nm-enum-utils.c b/shared/nm-glib-aux/nm-enum-utils.c index e105a4f5e5..e92797fdd1 100644 --- a/shared/nm-glib-aux/nm-enum-utils.c +++ b/shared/nm-glib-aux/nm-enum-utils.c @@ -143,7 +143,7 @@ _nm_utils_enum_to_str_full (GType type, return g_strdup (enum_value->value_nick); } else if (G_IS_FLAGS_CLASS (klass)) { GFlagsValue *flags_value; - GString *str = g_string_new (""); + GString *str = g_string_sized_new (16); unsigned uvalue = (unsigned) value; flags_separator = flags_separator ?: " ";