[gtk/wip/otte/dnd: 135/144] transform: Add optimization for common case



commit ef8513aa393a80fbc2a10a9f43eef45d530790c3
Author: Benjamin Otte <otte redhat com>
Date:   Thu Feb 20 00:02:19 2020 +0100

    transform: Add optimization for common case
    
    Transforming identity by an other transform does not mean we need to
    painstakingly apply the individual steps of other to construct a new
    transform, it means we can just return other.
    
    Or in math terms:
      I * B = B
    so just return B.

 gsk/gsktransform.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c
index 2d94d7e7a5..1c89414b7b 100644
--- a/gsk/gsktransform.c
+++ b/gsk/gsktransform.c
@@ -1619,6 +1619,12 @@ GskTransform *
 gsk_transform_transform (GskTransform *next,
                          GskTransform *other)
 {
+  if (gsk_transform_is_identity (next))
+    {
+      gsk_transform_unref (next);
+      return gsk_transform_ref (other);
+    }
+
   if (other == NULL)
     return next;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]