properties vs local variable

Mark Schonewille m.schonewille at economy-x-talk.com
Mon Mar 10 06:46:38 EDT 2014


Hi Terry,

It shouldn't matter much. Both propeties and variables exist in memory, 
if the stack containing the property is loaded into memory. If the stack 
it on disk but not in memory, it will be loaded the first time you 
access the property and may call a small delay.

If you have many nested properties, I could imagine that calling 
properties like

put the cProp["key1"]["key2"] into myArray
put the keys of myArray into myKeys
sort lines of myKeys numeric by item 1 of each
put myArray[line x of myKeys] into MyVar
-- etc

things may get awkwardly slow, but if you're just reading directly from 
a property, the difference with a local variable should be really small. 
If you want to know for sure, a few simple extra statements that put the 
milliseconds into a variable will show you the difference, as you 
already suggested.

There is one little thing that might affect speed and you really would 
have to rest this. LiveCode might look for a getProp handler when you 
call a property. This might take a millisecond or so. This is the only 
reason I can come up with, why using variables might be quicker.

If you think that your script is getting slow, there is probably another 
reason for it and using either properties or variables won't solve this 
issue. Perhaps you're having trouble because you're intervening with the 
GUI. If you explain what you're trying to do, perhaps we can find a 
better way to do it.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 3/10/2014 11:24, Terence Heaford wrote:
> I am just a beginner with LC and don’t want to spend hours reinventing the wheel so was hoping that someone can advise me which of the following is the quicker.
>
> I could go down the milliseconds route with every script I produce but….
>
> Is there a general rule that says
>
> put the uRows of me into tRows
> put line tRecNum to tRecNum + tRows - 1 of the uSelected of me into tSelectedData
>
> is quicker than using
>
> put line tRecNum to tRecNum + the uRows of me - 1 of the uSelected of me into tSelectedData
>
> or does it not really matter
>
> It is being used with a scrollbar so gets called quite a lot and tRows/the uRows of me appears in a number of lines in the method
>
> All the best
>
> Terry
> _______________________________________________
> 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