properties vs local variable
Dr. Hawkins
dochawk at gmail.com
Sat Mar 15 12:32:16 EDT 2014
On Mon, Mar 10, 2014 at 9:46 AM, J. Landman Gay <jacque at hyperactivesw.com>wrote:
> This will be the speed bottleneck. Array access is very fast, faster than
> almost any other method. As noted here, variable access is the fastest,
> followed by access to custom properties, but the difference is so minimal
> as to be insignificant.
I don't want to hijack anything, but this is my burning issue today.
I have cards that will become output; groups are copied from them to my
output window, and then manipulated.
It's also possible that cards will be added to that stack during program
execution (there are a couple of hundred districts with their own forms).
I'm waffling between something like
if pg = 1 then
put "group footer_1 " & " of " & tgCrd into tgGrp
else
put "group footer_c " & " of " & tgCrd into tgGrp
end if
if exists( tgGrp ) then
copy tgGrp to outTarget
do some other stuff with it
end if
The other approach would be to set a custom property full of this kind of
information, and then at program load (or when another card is added)
put the outControl of tgCrd into myTmp
split myTmp by return and space
put myTmp into outProps[the short name of tgCrd]
and then the routine becomes
if pg=1 then
put "footer_1" into tgProp
else
put "footer_c" into tgProp
end if
if outProps[cdName][tgProp] is not empty then
copy outProps[cdName][tgProp] of tgCrd
do other stuff
end if
So if using the custom properties of a stack in memory is faster (even if
having to parse the name?), then the first should be faster, while if a
multi-dimensional array is faster, the second is faster.
And I suppose there's a third, where I copy outProps[cdNam] to theProps,
when beginning to render a form. I recall someone discovering that under
some circumstances, it was worth the time to copy the subarray . . .
--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
More information about the use-livecode
mailing list