From: Timm Bäder Date: Wed, 15 Jan 2020 12:18:16 +0000 (+0100) Subject: csshorthandproperty: Try to avoid allocating a GString for 1 font X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~276 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d861dd5df84c057335e2355e5c2d951e767ec1ce;p=gtk4.git csshorthandproperty: Try to avoid allocating a GString for 1 font --- diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c index 290c6afdd0..6ae99f01a0 100644 --- a/gtk/gtkcssshorthandpropertyimpl.c +++ b/gtk/gtkcssshorthandpropertyimpl.c @@ -1143,18 +1143,26 @@ pack_font_description (GtkCssShorthandProperty *shorthand, v = (* query_func) (GTK_CSS_PROPERTY_FONT_FAMILY, query_data); if (v) { - int i; - GString *s = g_string_new (""); + if (_gtk_css_array_value_get_n_values (v) > 1) + { + int i; + GString *s = g_string_new (""); + + for (i = 0; i < _gtk_css_array_value_get_n_values (v); i++) + { + if (i > 0) + g_string_append (s, ","); + g_string_append (s, _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, i))); + } - for (i = 0; i < _gtk_css_array_value_get_n_values (v); i++) + pango_font_description_set_family (description, s->str); + g_string_free (s, TRUE); + } + else { - if (i > 0) - g_string_append (s, ","); - g_string_append (s, _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, i))); + pango_font_description_set_family (description, + _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, 0))); } - - pango_font_description_set_family (description, s->str); - g_string_free (s, TRUE); } v = (* query_func) (GTK_CSS_PROPERTY_FONT_SIZE, query_data);