[gtk/wip/baedert/css-values: 50/84] csscornervalue: Accept other values if x == y
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 50/84] csscornervalue: Accept other values if x == y
- Date: Thu, 16 Jan 2020 07:04:55 +0000 (UTC)
commit af17d6c9c7fa79301d08107f684d2abac587083f
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 8 09:11:02 2020 +0100
csscornervalue: Accept other values if x == y
Most corners are square, so x == y. In that case, just accept either of
them. This makes the corner value unnecessary.
In fact none of the corner values in the widget-factory are needed, so
this spares us around 500 corner value allocations.
css value stats before:
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428
and after:
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
SUM: 7872
8428 to 7872 is a 556 reduction (6.5%)
asdf
gtk/gtkcsscornervalue.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/gtk/gtkcsscornervalue.c b/gtk/gtkcsscornervalue.c
index 49b6bd1605..54f4480a0a 100644
--- a/gtk/gtkcsscornervalue.c
+++ b/gtk/gtkcsscornervalue.c
@@ -115,6 +115,12 @@ _gtk_css_corner_value_new (GtkCssValue *x,
{
GtkCssValue *result;
+ if (_gtk_css_value_equal (x, y))
+ {
+ _gtk_css_value_unref (y);
+ return x;
+ }
+
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_CORNER);
result->x = x;
result->y = y;
@@ -156,6 +162,9 @@ double
_gtk_css_corner_value_get_x (const GtkCssValue *corner,
double one_hundred_percent)
{
+ if (corner->class != >K_CSS_VALUE_CORNER)
+ return _gtk_css_number_value_get (corner, one_hundred_percent);
+
g_return_val_if_fail (corner != NULL, 0.0);
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, 0.0);
@@ -166,6 +175,9 @@ double
_gtk_css_corner_value_get_y (const GtkCssValue *corner,
double one_hundred_percent)
{
+ if (corner->class != >K_CSS_VALUE_CORNER)
+ return _gtk_css_number_value_get (corner, one_hundred_percent);
+
g_return_val_if_fail (corner != NULL, 0.0);
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, 0.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]