Making the move...
Rob Cozens
rcozens at pon.net
Wed Mar 22 12:11:43 EST 2006
Geoff,
> Because it gets rid of a bunch of if statements in your repeat loop.
> It costs you a bit in that the repeat structure is duplicated in the
> routine that simply counts, so that's a tradeoff. But your repeat ends
> up being faster because you aren't doing tests each time through.
>
> Further, your code ends up being easier to understand, because one
> routine simply counts, while one returns data -- more clear.
>
The function here is to count, and optionally select data from, records
that match search criteria. To count and select in separate logic
means parsing all records twice.
I did find this logic:
repeat for each line itemNumber in itemList
put sdbFieldNumber(itemNumber) into itemNumber
that should be evaluated once all error checks are passed:
put empty into rawItemNumbers
repeat for each line itemNumber in itemList
put sdbFieldNumber(itemNumber)&return after rawItemNumers
end repeat
put rawItemNumers into itemList
and removed from the repeat loop...thanks.
Other than that, I don't see much efficiency to be gained here.
Also, if you look closely at "if countOnly" statements, you will find
that they are in repeat exit logic, and never get executed more than
once.
Rob Cozens
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list