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.
This commit is contained in:
Thomas Haller 2020-03-30 12:15:05 +02:00
parent 686b58571b
commit d5d7b4781e

View file

@ -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 ?: " ";