Keys of a custom property array

Monte Goulding monte at sweattechnologies.com
Mon Mar 4 18:18:30 EST 2013


On 05/03/2013, at 9:49 AM, Richard Gaskin wrote:

> Mark's notes there describe a future challenge for the parser, but don't address the current storage format of arrays in custom props.
> 
> Try this:
> 
> Set the value of a custom property to an array, and save that stack.
> 
> Write out a binfile containing that same array passed through arrayEncode.
> 
> Now read the encoded array file as binary, delete the first char (it will be 5, a flag noting it's an array), and read the stack file as binary and see if the encoded array data is in the stack data.
> 
> In my tests it is, suggesting that the format used for encoded arrays is the same format arrays are stored in when put into a custom property.
> 
> This makes sense, given that arrays are memory-location-specific hashes, so they'd need a generic way to store it in a custom prop, and they already came up with the arrayEncode function at roughly the same time as we were able to save arrays into props.
> 
> This also explains why accessing these "unnatural" arrays are measurably slower than storing an equivalent one-dimensional array as a property set, since the latter doesn't have the overhead of running through arrayDecode.

I agree it makes total sense to use the same format when reading/writing to disk. As all the data is loaded into memory anyway I wonder how much extra time it would take to turn it into a pointer that was just as fast to access as a regular array.... perhaps that could be done at first access?

Either way my guess is you are having to do many iterations to see a measurable difference unless you are dealing with an amount of data that would be better in a database... so no matter what the engine needs to do the reason why we can't deal with multi-dimensional custom properties is because of the syntax ambiguity. The simplest resolution to the ambiguity is to only allow array syntax on sets so the set name must be the first key. If you need to access one of the regular custom properties there is already a mechanism in place for that by using empty as the set name.

get the customKeys[""]["dgData"]["1"]

get the customKeys["dgProps"]["row template"]

Cheers

--
M E R Goulding 
Software development services
Bespoke application development for vertical markets

mergExt - There's an external for that!




More information about the use-livecode mailing list