[gtk/wip/baedert/css-values: 67/102] cssnumbervalue: Add early-outs to transition code
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 67/102] cssnumbervalue: Add early-outs to transition code
- Date: Sat, 18 Jan 2020 07:51:03 +0000 (UTC)
commit e31c0898e56c6e940d26767ba15a589ac874700d
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 8 09:42:23 2020 +0100
cssnumbervalue: Add early-outs to transition code
we don't need to do the calculation at all if the progress is 0 or 1
anyway.
We also sometimes transition from 0 to 0 etc., so we can short-circuit
that as well by doing the fast pointer-equality check and relying on the
singletons.
gtk/gtkcssnumbervalue.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index f5e574c81d..83fa257f01 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -115,6 +115,15 @@ gtk_css_number_value_transition (GtkCssValue *start,
{
GtkCssValue *result, *mul_start, *mul_end;
+ if (progress == 0)
+ return _gtk_css_value_ref (start);
+
+ if (progress == 1)
+ return _gtk_css_value_ref (end);
+
+ if (start == end)
+ return _gtk_css_value_ref (start);
+
mul_start = gtk_css_number_value_multiply (start, 1 - progress);
mul_end = gtk_css_number_value_multiply (end, progress);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]