Parent of Target

Ali Lloyd ali.lloyd at livecode.com
Thu Aug 10 03:32:02 EDT 2017


>
> Jacque recently showed me the speed difference between explicitly
> writing out the element of an object reference:
>
>    get the width of btn 1 of cd 2 of stack "MyStack"
>
> ...vs other forms like long IDs:
>
>    put the long is of btn 1 of cd 2 of stack "MyStack" into t5Obj
>    get teh width of tObj
>
> The latter is much slower, yet long IDs are so good to work with.
>

The only reason this is true is that in the second case you are resolving
the object twice. It is not true in general - the second time the long id
is used it will use the id cache which is constant time, whereas "button n"
is O(n). Try benchmarking repeated use of the stored long id vs the number
version, especially if the numbers are large.

So it's horses for courses. If it's a one-shot object access then the
number form is faster. For repeated use, get the long id.

>
>



More information about the Use-livecode mailing list