[Pkg-wmaker-commits] [wmbubble] 48/207: GCC seems to make significantly more efficient code when walking pointers instead of just array dereferencing, so use that here.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 04:18:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbubble.

commit 1aabd8ee2041f31ab045c33d3699f149cd017d87
Author: Robert Jacobs <rnjacobs at mit.edu>
Date:   Sat Jul 30 21:46:25 2011 -0700

    GCC seems to make significantly more efficient code when walking
    pointers instead of just array dereferencing, so use that here.
---
 bubblemon.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/bubblemon.c b/bubblemon.c
index e812300..7f62585 100644
--- a/bubblemon.c
+++ b/bubblemon.c
@@ -438,20 +438,20 @@ int main(int argc, char **argv) {
 		}
 #endif
 
-		/* drawing borders: 50M times in 49sec -> 1020408fps or 0.98us/frame */
+		/* drawing borders: 50M times in 54sec -> 925926fps or 1.08us/frame */
 		int xx,yy;
-		unsigned char * from=bm.rgb_buf;
+		unsigned char * from;
 
-		for (xx=0;xx<BOX_SIZE*3;xx++) {
-			from[xx]/=4;
-			from[xx+BOX_SIZE*(BOX_SIZE-1)*3]=(255+from[xx+BOX_SIZE*(BOX_SIZE-1)*3])/2;
+		for (from=bm.rgb_buf,xx=0;xx<BOX_SIZE*3;from++,xx++) {
+			from[0]/=4;
+			from[BOX_SIZE*(BOX_SIZE-1)*3]=(255+from[BOX_SIZE*(BOX_SIZE-1)*3])/2;
 		}
 
-		for (yy=0;yy<BOX_SIZE*BOX_SIZE*3;yy+=BOX_SIZE*3) {
-			from[yy  ]/=4; from[yy+1]/=4; from[yy+2]/=4;
-			from[yy+(BOX_SIZE-1)*3  ]=(255+from[yy+(BOX_SIZE-1)*3  ])/2;
-			from[yy+(BOX_SIZE-1)*3+1]=(255+from[yy+(BOX_SIZE-1)*3+1])/2;
-			from[yy+(BOX_SIZE-1)*3+2]=(255+from[yy+(BOX_SIZE-1)*3+2])/2;
+		for (from=bm.rgb_buf,yy=0;yy<BOX_SIZE;yy++,from+=BOX_SIZE*3) {
+			from[0]/=4; from[1]/=4; from[2]/=4;
+			from[(BOX_SIZE-1)*3  ]=(255+from[(BOX_SIZE-1)*3  ])/2;
+			from[(BOX_SIZE-1)*3+1]=(255+from[(BOX_SIZE-1)*3+1])/2;
+			from[(BOX_SIZE-1)*3+2]=(255+from[(BOX_SIZE-1)*3+2])/2;
 		}
 
 		/* Our colorspace conversion: 3M times in 56sec -> 53561fps or 19us/frame */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbubble.git



More information about the Pkg-wmaker-commits mailing list