Reverse a list
Geoff Canyon
gcanyon at gmail.com
Mon Feb 16 22:18:45 EST 2015
It's important to note that the efficiency is all/mostly in the function
call, not in the execution of the function itself. So for really short
functions that will be called many times, this is significant. For longer
functions, the difference all but vanishes:
on mouseUp
put 1000 into n
--
put the millisecs into t
repeat n
put Foo1() into r2
end repeat
put the millisecs - t into t1
--
put the millisecs into t
repeat n
put Foo2() into r2
end repeat
put the millisecs - t into t2
--
put t1 && t2
end mouseUp
function Foo1
repeat 10000
get "Hello"
end repeat
return it
end Foo1
private function Foo2
repeat 10000
get "Hello"
end repeat
return it
end Foo2
puts 629 622 for me
On Mon, Feb 16, 2015 at 10:10 PM, Jim Lambert <jiml at netrin.com> wrote:
> RichardG wrote:
> >
> > I would imagine that a handler in the same
> > script as the caller would be faster than having it just about any other
> > place, but to limit its scope trims the execution time by a surprising
> > amount.
> >
>
> Whoda thunk!
>
> > I think my new habit is to declare everything as private unless I know I
> > need it available to other scripts.
>
> Me too.
>
> > Thanks again. Excellent discovery.
>
> Ditto.
>
> Jim Lambert
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list