At 1:02 PM -0700 9/22/00, Kerry Thompson wrote:
>Ok, for a lazy Friday afternoon, here's some code I'm working on 
>optimizing (D8):
>
>   -- Check to see if we have a card from each list and if they match
>   -- The first card can be from list 1 or 2; the second card can 
>also be from list 1 or 2
>   if ((getPos(pList1, pBoard[pCard1]) > 0) AND (getPos(pList2, 
>pBoard[pCard2]) > 0) AND \
>         (getPos(pList1, pBoard[pCard1]) = getPos(pList2, 
>pBoard[pCard2]))) OR \
>      ((getPos(pList2, pBoard[pCard1]) > 0) AND (getPos(pList1, 
>pBoard[pCard2]) > 0) AND \
>         (getPos(pList2, pBoard[pCard1]) = getPos(pList1, 
>pBoard[pCard2]))) then --they are a match
>

Kerry,

Without really understanding what you are trying to do here, the 
first thing I notice is that you are doing a bunch of repitive 
calculations.  I would move these into local variables before the big 
if statement.  For example I would do something like this:

   card1OfBoard = pBoard[pCard1]
   card2OfBoard = pBoard[pCard2]
   posOfCard1InList1 = getPos(pList1, card1OfBoard)
   posOfCard1InList2 = getPos(pList1, card2OfBoard)
   posOfCard2InList1 = getPos(pList2, card1OfBoard)
   posOfCard2InList2 = getPos(pList2, card2OfBoard)

Then re-write your if using these local variables.  I'm sure it would 
be faster and would probably wind up being easier to read also.

Irv
-- 
Lingo / Director / Shockwave development for all occasions.

        (Over two millions lines of Lingo code served!)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to