Archived

This topic is now archived and is closed to further replies.

owl

which's faster? (+ or *)

Recommended Posts


          
for (int x=0;x<Width;x++)
  for (int y=0;y<Height;y++)
    *(Buffer+x+(y*Width)) = color;


//or


for (int x=0;x<Width;x++)
{
  int i = 0;
  for (int y=0;y<Height;y++)
  {
    *(Buffer+x+i) = color;
    i += Width;
  }
}
          
My guess is that the second is faster.
So anyways, in this sense, 4 dimensions is no good to live in, if you want to think about living in a different world, try 5. pouya [edited by - xaxa on January 19, 2003 5:37:59 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

  
pitch = Pitch - width;
offset = Buffer;

for( unsigned yCnt = height; --yCnt; )
{
for( unsigned xCnt = width; --xCnt; )
*Buffer++ = color;

offset+=pitch;
}
[source]

is faster but require extra tests

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

  
pitch = Pitch - width;
offset = Buffer;

for( unsigned yCnt = height; --yCnt; )
{
for( unsigned xCnt = width; --xCnt; )
*Buffer++ = color;

offset+=pitch;
}
[source]

is faster but require extra tests

Share this post


Link to post
Share on other sites

    
mypitch=Pitch
-Width;offset
=Buffer;for(
unsigned yCnt
=Height;--yCnt
;){for(unsigned
xCnt=Width;--xCnt
;)*Buffer++=color
;offset+=mypitch;}


is faster but require extra tests

... there it is

--
I want to kill everyone, satan is good, satan is our pal
Astrobotnia

[edited by - cnstrnd on January 19, 2003 6:21:58 AM]

Share this post


Link to post
Share on other sites