[PATCH 5/7] damage: Micro-tune the ReportNonEmpty case

Adam Jackson ajax at redhat.com
Mon Sep 2 07:19:00 PDT 2013


gcc doesn't seem to be smart enough to short-circuit the RegionUnion
call when the region was previously empty.  Possibly this was partly
that the second argument to RegionUnion() isn't const.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 miext/damage/damage.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 63fe89a..246ade6 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1904,7 +1904,6 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr pDamageRegion)
 {
     BoxRec tmpBox;
     RegionRec tmpRegion;
-    Bool was_empty;
 
     switch (pDamage->damageLevel) {
     case DamageReportRawRegion:
@@ -1929,11 +1928,12 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr pDamageRegion)
         }
         break;
     case DamageReportNonEmpty:
-        was_empty = !RegionNotEmpty(&pDamage->damage);
-        RegionUnion(&pDamage->damage, &pDamage->damage, pDamageRegion);
-        if (was_empty && RegionNotEmpty(&pDamage->damage)) {
-            (*pDamage->damageReport) (pDamage, &pDamage->damage,
-                                      pDamage->closure);
+        if (!RegionNotEmpty(&pDamage->damage)) {
+	    RegionUnion(&pDamage->damage, &pDamage->damage, pDamageRegion);
+	    if (RegionNotEmpty(&pDamage->damage)) {
+		(*pDamage->damageReport) (pDamage, &pDamage->damage,
+					  pDamage->closure);
+            }
         }
         break;
     case DamageReportNone:
-- 
1.8.3.1



More information about the xorg-devel mailing list