diff options
author | Benjamin Otte <otte@redhat.com> | 2020-02-20 00:02:19 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2020-02-21 18:19:16 +0100 |
commit | 41ef6e9fa5c22d3a889f82f5fe96f633cdd6959d (patch) | |
tree | a05f64fa1378760629494de28d069e010a4a6f80 /gsk/gsktransform.c | |
parent | d7d7957b04a1afdb1008cad4512c25e5c2e711a8 (diff) | |
download | gtk+-41ef6e9fa5c22d3a889f82f5fe96f633cdd6959d.tar.gz |
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.
Diffstat (limited to 'gsk/gsktransform.c')
-rw-r--r-- | gsk/gsktransform.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c index c8e0d321b7..df6cb63bdd 100644 --- a/gsk/gsktransform.c +++ b/gsk/gsktransform.c @@ -1622,6 +1622,12 @@ gsk_transform_transform (GskTransform *next, if (other == NULL) return next; + if (gsk_transform_is_identity (next)) + { + gsk_transform_unref (next); + return gsk_transform_ref (other); + } + next = gsk_transform_transform (next, other->next); return other->transform_class->apply (other, next); } |