Increased memory use should be nil: it's a single additional hash per model class. The attributes themselves are in the hash by ref of course, so no extra there.
I'm minimizing CPU use by having code which executes only once per SC.Record.extend call, and does stuff once per extended property, so again once per model class. Below is my current (fully armed and operational) implementation. There are some things here which would slow down if we were doing it recursively or extensively, but each line of code is being called a max of once per SC.Record.extend({...}) property over the lifetime of the app.
extend: function() {
var ret = SC.Object.extend.apply(this, arguments);
if(SC.Query) SC.Query._scq_didDefineRecordType(ret);
ret._screc_listAttrs.apply(ret, arguments); // <-- new call
return ret;
},
/* @private - expose attributes at the class level for introspection. */
_screc_listAttrs: function() {
// Clone current list for the subclass.
var recordAttributes = SC.clone(this.recordAttributes);
var hash, property, value,
i, len = arguments.length;
for (i = 0; i < len; i++) {
hash = arguments[i];
if (SC.typeOf(hash) !== SC.T_HASH) continue;
for (property in hash) {
value = hash[property];
if (SC.kindOf(value, SC.RecordAttribute)) {
recordAttributes[property] = value;
}
}
}
this.recordAttributes = recordAttributes;
}