On Wed, May 21, 2014 at 6:02 PM, Timothy Arceri <t_arc...@yahoo.com.au> wrote: > 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_arc...@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; > }
Have you actually compared the generated code? I find it can be fairly instructive to do so... btw, there's a likely() (and unlikely() ) primitive (in p_compiler.h) which will indicate to gcc whether a particular condition is likely or unlikely, so that it can adjust its code generation accordingly. -ilia _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev