All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 6/7] uxa: Refactor early-exit paths of uxa_try_driver_composite().
Date: Sat, 17 Nov 2012 13:11:13 -0800	[thread overview]
Message-ID: <1353186674-7234-6-git-send-email-eric@anholt.net> (raw)
In-Reply-To: <1353186674-7234-1-git-send-email-eric@anholt.net>

Saves 200b of code at -O2.  I noticed this while fixing up the warning
in HEAD~1.
---
 uxa/uxa-render.c |   79 +++++++++++++++++++-----------------------------------
 1 file changed, 28 insertions(+), 51 deletions(-)

diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index d783ea2..3678f6a 100644
--- a/uxa/uxa-render.c
+++ b/uxa/uxa-render.c
@@ -965,8 +965,9 @@ uxa_try_driver_composite(CARD8 op,
 	int xDst_copy = 0, yDst_copy = 0;
 	int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y;
 	PixmapPtr pSrcPix, pMaskPix = NULL, pDstPix;
-	PicturePtr localSrc, localMask = NULL;
+	PicturePtr localSrc = NULL, localMask = NULL;
 	PicturePtr localDst = pDst;
+	int ret = 0;
 
 	if (uxa_screen->info->check_composite &&
 	    !(*uxa_screen->info->check_composite) (op, pSrc, pMask, pDst, width, height))
@@ -1018,9 +1019,8 @@ uxa_try_driver_composite(CARD8 op,
 	pDstPix =
 	    uxa_get_offscreen_pixmap(localDst->pDrawable, &dst_off_x, &dst_off_y);
 	if (!pDstPix) {
-		if (localDst != pDst)
-			FreePicture(localDst, 0);
-		return -1;
+		ret = -1;
+		goto error;
 	}
 
 	xDst += localDst->pDrawable->x;
@@ -1031,9 +1031,8 @@ uxa_try_driver_composite(CARD8 op,
 				      width, height,
 				      &xSrc, &ySrc);
 	if (!localSrc) {
-		if (localDst != pDst)
-			FreePicture(localDst, 0);
-		return 0;
+		ret = 0;
+		goto error;
 	}
 
 	if (pMask) {
@@ -1042,72 +1041,38 @@ uxa_try_driver_composite(CARD8 op,
 					     width, height,
 					     &xMask, &yMask);
 		if (!localMask) {
-			if (localSrc != pSrc)
-				FreePicture(localSrc, 0);
-			if (localDst != pDst)
-				FreePicture(localDst, 0);
-
-			return 0;
+			ret = 0;
+			goto error;
 		}
 	}
 
 	if (!miComputeCompositeRegion(&region, localSrc, localMask, localDst,
 				      xSrc, ySrc, xMask, yMask, xDst, yDst,
 				      width, height)) {
-		if (localSrc != pSrc)
-			FreePicture(localSrc, 0);
-		if (localMask && localMask != pMask)
-			FreePicture(localMask, 0);
-		if (localDst != pDst)
-			FreePicture(localDst, 0);
-
-		return 1;
+		ret = 1;
+		goto error;
 	}
 
 	pSrcPix = uxa_get_offscreen_pixmap(localSrc->pDrawable,
 					   &src_off_x, &src_off_y);
 	if (!pSrcPix) {
-		REGION_UNINIT(screen, &region);
-
-		if (localSrc != pSrc)
-			FreePicture(localSrc, 0);
-		if (localMask && localMask != pMask)
-			FreePicture(localMask, 0);
-		if (localDst != pDst)
-			FreePicture(localDst, 0);
-
-		return 0;
+		ret = 0;
+		goto error;
 	}
 
 	if (localMask) {
 		pMaskPix = uxa_get_offscreen_pixmap(localMask->pDrawable,
 						    &mask_off_x, &mask_off_y);
 		if (!pMaskPix) {
-			REGION_UNINIT(screen, &region);
-
-			if (localSrc != pSrc)
-				FreePicture(localSrc, 0);
-			if (localMask && localMask != pMask)
-				FreePicture(localMask, 0);
-			if (localDst != pDst)
-				FreePicture(localDst, 0);
-
-			return 0;
+			ret = 0;
+			goto error;
 		}
 	}
 
 	if (!(*uxa_screen->info->prepare_composite)
 	    (op, localSrc, localMask, localDst, pSrcPix, pMaskPix, pDstPix)) {
-		REGION_UNINIT(screen, &region);
-
-		if (localSrc != pSrc)
-			FreePicture(localSrc, 0);
-		if (localMask && localMask != pMask)
-			FreePicture(localMask, 0);
-		if (localDst != pDst)
-			FreePicture(localDst, 0);
-
-		return -1;
+		ret = -1;
+		goto error;
 	}
 
 	if (pMask) {
@@ -1156,6 +1121,18 @@ uxa_try_driver_composite(CARD8 op,
 	}
 
 	return 1;
+
+error:
+	REGION_UNINIT(screen, &region);
+
+	if (localSrc && localSrc != pSrc)
+		FreePicture(localSrc, 0);
+	if (localMask && localMask != pMask)
+		FreePicture(localMask, 0);
+	if (localDst != pDst)
+		FreePicture(localDst, 0);
+
+	return ret;
 }
 
 /**
-- 
1.7.10.4

  parent reply	other threads:[~2012-11-17 21:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-17 21:11 [PATCH 1/7] configure.ac: Fix bad syntax for test calls Eric Anholt
2012-11-17 21:11 ` [PATCH 2/7] intel: Factor out the repeated swap fallback code Eric Anholt
2012-11-17 21:11 ` [PATCH 3/7] intel: Add printf attribute to intel_debug_fallback() Eric Anholt
2012-11-17 21:11 ` [PATCH 4/7] uxa: Fix const-cast warning Eric Anholt
2012-11-17 21:11 ` [PATCH 5/7] uxa: Work around uninitialized-value warning Eric Anholt
2012-11-17 21:11 ` Eric Anholt [this message]
2012-11-17 21:11 ` [PATCH 7/7] Don't mark the list of chipsets const when we just cast the const away Eric Anholt
2012-11-18 11:54   ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353186674-7234-6-git-send-email-eric@anholt.net \
    --to=eric@anholt.net \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.