Subj : Re: [spidermonkey] getter/setter for all properties of an object To : netscape.public.mozilla.jseng From : Brendan Eich Date : Wed Aug 17 2005 09:54 pm franck wrote: > Now I'm using JSCLASS_SHARE_ALL_PROPERTIES in the JSClass flags, and I > defined an ( empty ) newEnumerate hook to avoid for-each to detect > anything. > > If I understood, there is no way to avoid the property name to be stored > in the object ( JSPROP_SHARED is only for the value ) The name is not stored in the object, it's shared in a type-inference tree in the JSRuntime. Don't worry about its overhead unless you can prove it matters. > var obj = new ObjectEx() > for ( var i=0; i<100000; i++ ) > obj[i] = some_datas; > > This will create 100000 strings ( the name of the properties > '0'...'99999' ) in the object ? No. First, the integer property ids that fit in a jsval (or jsid) are stored as tagged integers, not as strings. Second that big runtime-wide lexicographic tree I mentioned above is where properties are stored. The object owns a hash table of pointers into that structure, which is much smaller. /be .