소스 검색

LibGfx: Add fast path for multiply() with identity transforms

This is a no-op, and exiting early is useful as it cuts time spent in
AffineTransform::multiply() from 3% to 2% when hovering links on
ziglang.org.
Andreas Kling 1 년 전
부모
커밋
c69b266e43
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      Userland/Libraries/LibGfx/AffineTransform.cpp

+ 2 - 0
Userland/Libraries/LibGfx/AffineTransform.cpp

@@ -108,6 +108,8 @@ AffineTransform& AffineTransform::set_translation(FloatPoint t)
 
 
 AffineTransform& AffineTransform::multiply(AffineTransform const& other)
 AffineTransform& AffineTransform::multiply(AffineTransform const& other)
 {
 {
+    if (other.is_identity())
+        return *this;
     AffineTransform result;
     AffineTransform result;
     result.m_values[0] = other.a() * a() + other.b() * c();
     result.m_values[0] = other.a() * a() + other.b() * c();
     result.m_values[1] = other.a() * b() + other.b() * d();
     result.m_values[1] = other.a() * b() + other.b() * d();