[gtk/wip/baedert/css-values: 1/11] csshorthandproperty: Try to avoid allocating a GString for 1 font
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 1/11] csshorthandproperty: Try to avoid allocating a GString for 1 font
- Date: Fri, 17 Jan 2020 15:34:43 +0000 (UTC)
commit f1daa884e9276b30b7503f1e2af23b1f30f5b7f0
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 15 13:18:16 2020 +0100
csshorthandproperty: Try to avoid allocating a GString for 1 font
gtk/gtkcssshorthandpropertyimpl.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]