Keys of a custom property array

Richard Gaskin ambassador at fourthworld.com
Sun Mar 3 22:27:50 EST 2013


It seems there are two types of arrays storable in LC props, what I like 
to call "Natural" and "Unnatural":

"Natural" arrays are one-dimensional, and fit into the traditional view 
of custom props as having one or more property sets, each of which is 
comprised of properties, each of which has a key and a value.

"Unnatural" arrays are what you have when you story any array into a 
custom property value.  I haven't fully tested this theory out, but it 
seems to be that when you store an array into a custom property the 
engine first runs it through arrayEncode, and to access it uses 
arrayDecode, both of which are notoriously slow operations since they 
require iterating through the complete structure to translate it from 
the RAM-address-optimized version of the array in memory and it's 
simpler linear structure for storage.

The difference between the two is why some of the array syntax like "get 
myArray[key1][key2]" can't be used with arrays stored in custom props, 
because in actuality the custom property is only one level deep, and 
anything deeper is emulated through arrayEncode/arrayDecode.

Given this, though I don't have my benchmarks with me at the moment, I 
believe that if you can fit the data you need into the "natural" array 
storage of custom properties and property sets, and use "the customkeys" 
to access those directly from the object record, you should see the most 
minimal impact on both execution time and memory space.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for Desktop, Mobile, and Web
  ____________________________________________________________
  Ambassador at FourthWorld.com        http://www.FourthWorld.com





More information about the use-livecode mailing list