object.hasOwnProperty usage
I think the way the hasOwnProperty method is used in Ext JS is not very efficient. :-?
See my modification below. The new code avoids long property lookups all the way to Object by caching the hasOwnProperty method in a local variable. This should improve performance.
Code:
Ext.define('Ext.util.Observable', {
...
removeManagedListener : function(item, ename, fn, scope) {
var me = this,
...,
hasOwn = Object.prototype.hasOwnProperty; // <-- added
if (typeof ename !== 'string') {
options = ename;
for (ename in options) {
// if (options.hasOwnProperty(ename)) {
if (hasOwn.call(options, ename)) {
config = options[ename];
if (!me.eventOptionsRe.test(ename)) {
me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope);
}
}
}
}
...
},
***Edit
Performance improvement is minor, but it still might be worth it because it's a simple change.
http://jsperf.com/hasownproperty-caching