[Mesa-dev] [PATCH] gallium: reflect likely outcome in execution flow

Timothy Arceri t_arceri at yahoo.com.au
Wed May 21 15:02:16 PDT 2014


Unless we run out of memory the old if statement would always fail so reflect the more likely outcome. Should be be faster most of the time and slightly cleaner looking code.

Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
 src/gallium/auxiliary/util/u_upload_mgr.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index 744ea2e..99f9a08 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -247,11 +247,10 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
    enum pipe_error ret = u_upload_alloc(upload, min_out_offset, size,
                                         out_offset, outbuf,
                                         (void**)&ptr);
-   if (ret != PIPE_OK)
-      return ret;
+   if (ret == PIPE_OK)
+      memcpy(ptr, data, size);
 
-   memcpy(ptr, data, size);
-   return PIPE_OK;
+   return ret;
 }
 
 
-- 
1.9.0



More information about the mesa-dev mailing list