A code style question

Richard Gaskin ambassador at fourthworld.com
Tue Jan 20 12:47:22 EST 2015


The first is slightly faster, but they don't return the same result - 
running the code below I always get:

6 8 false
this card 1000

Did I mess up the test somewhere?


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) 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 newID is not empty 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
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list