That's a good list.

> Don't put a computed expression in a the head statement of a
> for-next loop.

This reminds me of a somewhat more general piece of advice: don't do
anything inside the loop that you could instead do once before the
loop.  A common newbie mistake in using RGBSurfaces is to write
something like:

  for y = 0 to ymax
    for x = 0 to xmax
      DoSomethingWith pic.RGBSurface.Pixel(x,y)
    next
  next

which is horribly, horribly slow, since the pic.RGBSurface call is
(usually) very expensive.  Instead, do:

  Dim surf as RGBSurface = pic.RGBSurface
  for y = 0 to ymax
    for x = 0 to xmax
      DoSomethingWith surf.Pixel(x,y)
    next
  next

This is dramatically faster.  But it doesn't apply only to RGBSurfaces;
in general, anything you can do outside the loop, do outside the loop
(when speed counts).

HTH,
- Joe

--
Joe Strout -- [EMAIL PROTECTED]
Verified Express, LLC     "Making the Internet a Better Place"
http://www.verex.com/

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to