I figured the first version would be faster, since it only checks each thing once, where the second version tests some booleans twice, but this isn't going to be called repeatedly, so maximum performance isn't an issue.
I was more curious about the readability, because I thought I might be the odd one out here, and it seems I am. The nested if statements in the first one, and the duplicated set the baseID of this stack to "this card" offend my eye. Once I realized I needed to test for "exists" OR "is among" more than once I used a separate function for those. Along with an inline "if" function I already had, and switching from a stack property to a local, I came up with: local baseID function baseID newID put iff(validID(newID),newID, \ iff(validID(baseID), baseID,"this card")) into baseID return baseID end baseID3 function iff X,T,F if X then return T else return F end iff function validID I return ((I is among the items of "this card,card list,background list,stack list") or exists(I)) end validID Maybe not everyone's cup of tea, but clear to me. On Tue, Jan 20, 2015 at 1:14 PM, Richard Gaskin <ambassa...@fourthworld.com> wrote: > Thanks for the fix. Once I took care of the email line wrap it ran well. > The first version is still slightly faster, and to my eye more readable, so > I'd go with that. > > > > on mouseUp > put 1000 into tIterations > -- > set the baseID of this stack to empty > put the millisecs into t > repeat tIterations > put baseID1(1000) into r1 > end repeat > put the millisecs - t into t1 > -- > set the baseID of this stack to empty > put the millisecs into t > repeat tIterations > put baseID2(1000) into r2 > end repeat > put the millisecs - t into t2 > -- > put t1 && t2 && (r1=r2) &cr& r1 && r2 > end mouseUp > > function baseID1 newID > if newID is empty then > if not exists (the baseID of this stack) then > set the baseID of this stack to "this card" > end if > else > if exists(newID) or \ > newID is among the items of "this card,card list,background > list,stack list" then > set the baseID of this stack to newID > else > set the baseID of this stack to "this card" > end if > end if > return the baseID of this stack > end baseID1 > > > function baseID2 newID > if (newID is not empty and not exists(newID)) or \ > (newID is empty and not exists(the baseID of this stack)) then \ > set the baseID of this stack to "this card" > if exists(newID) or \ > newID is among the items of "this card,card list,background > list,stack list" then \ > set the baseID of this stack to newID > return the baseID of this stack > end baseID2 > > -- > Richard Gaskin > Fourth World Systems > Software Design and Development for the Desktop, Mobile, and the Web > ____________________________________________________________________ > ambassa...@fourthworld.com http://www.FourthWorld.com > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode