csscolorvalue: check for singletons in new_literal
authorTimm Bäder <mail@baedert.org>
Sun, 12 Jan 2020 14:53:26 +0000 (15:53 +0100)
committerTimm Bäder <mail@baedert.org>
Sat, 18 Jan 2020 07:49:51 +0000 (08:49 +0100)
Gets rid of another ~400 GtkCssValue instances in the widget-factory.

gtk/gtkcsscolorvalue.c

index 520a6ee852cc7be078eb8bdf1b52a83eae3e2038..80cc7a3d21076ef4aef546ca3543414a56b3eb14 100644 (file)
@@ -507,6 +507,12 @@ _gtk_css_color_value_new_literal (const GdkRGBA *color)
 
   g_return_val_if_fail (color != NULL, NULL);
 
+  if (gdk_rgba_equal (color, &white_singleton.sym_col.rgba))
+    return _gtk_css_value_ref (&white_singleton);
+
+  if (gdk_rgba_equal (color, &transparent_black_singleton.sym_col.rgba))
+    return _gtk_css_value_ref (&transparent_black_singleton);
+
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
   value->type = COLOR_TYPE_LITERAL;
   value->is_computed = TRUE;