Loading

Paste #p5g59rwbi

  1. From 4b9497887dfc4f60df32729065aff39f70011b9f Mon Sep 17 00:00:00 2001
  2. From: Benjamin Otte <otte@redhat.com>
  3. Date: Thu, 20 Feb 2020 00:02:19 +0100
  4. Subject: [PATCH] transform: Add optimization for common case
  5.  
  6. Transforming identity by an other transform does not mean we need to
  7. painstakingly apply the individual steps of other to construct a new
  8. transform, it means we can just return other.
  9.  
  10. Or in math terms:
  11.   I * B = B
  12. so just return B.
  13. ---
  14.  gsk/gsktransform.c | 2 ++
  15.  1 file changed, 2 insertions(+)
  16.  
  17. diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c
  18. index c8e0d321b7..b195bd0fa7 100644
  19. --- a/gsk/gsktransform.c
  20. +++ b/gsk/gsktransform.c
  21. @@ -1619,6 +1619,8 @@ GskTransform *
  22.  gsk_transform_transform (GskTransform *next,
  23.                           GskTransform *other)
  24.  {
  25. +  if (gsk_transform_is_identity (next))
  26. +    return gsk_transform_ref (other);
  27.    if (other == NULL)
  28.      return next;
  29.  
  30. --
  31. 2.24.1