Jump to content
  • Advertisement

Archived

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

owl

which's faster? (+ or *)

This topic is 5663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!