renan-guimaraes / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Change default properties on JSON objects for greater efficiency #323

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Right now, TdwsJSONValue has a default array property of:

Values[const index : Variant] : TdwsJSONValue

This means that any time anyone uses the most intuitive indexing syntax on any 
dwsJSON object, "myObj[index]", it will turn the index variable into a Variant, 
call GetValue which decodes the variant, and indexes into Items or Names as 
appropriate.

JSON arrays are always indexed by ordinal, and JSON objects are always indexed 
by name.  Knowing this, it would make sense to set Items as the default 
property for TdwsJSONObject, and Elements for TdwsJSONArray.  This way, when 
working with objects that are known at compile-time to be one of those two 
classes, the compiler can produce more optimal code without the programmer 
having to explicitly specify the appropriate property name.

It will also improve debuggability, because the debugger apparently doesn't 
like Variants, and can't evaluate a call to Values.

Original issue reported on code.google.com by masonwhe...@gmail.com on 31 Dec 2012 at 6:22

GoogleCodeExporter commented 9 years ago

Original comment by zar...@gmail.com on 18 Apr 2013 at 7:30