-
17 May 2012 10:09 AM #1
Delegate Ext.Object.chain to Object.create
Delegate Ext.Object.chain to Object.create
This is a performance improvement suggestion.
Ext.Object.chain could be delegated (on supported platforms) to Object.create. This would improve performance.
Object.create
Ext.Object.chain
Try this test. You will see that Object.create is at least 50% faster.
EDIT
Also, see this similar delegation Ext.Object.getKeys --> Object.keys
*** EDIT 5/18/12Code:var obj = { key1: 'xxx', key2: 'yyy', key3: 'zzz', key4: 'www', key5: 'aaa' } console.time('chain'); for (var i=0; i<10000; i++) { Ext.Object.chain(obj); } console.timeEnd('chain'); console.time('create'); for (var i=0; i<10000; i++) { Object.create(obj); } console.timeEnd('create');
See how the Compose library checks if Object.create is available.Last edited by LesJ; 18 May 2012 at 5:49 AM. Reason: Add Compose link
-
19 May 2012 3:57 AM #2
Hello, I hope we are paying attention to performance improvement suggestions in this forum.

This simple and effective change will speed up object composition in Ext JS. This will make a difference in an application where you have thousands of objects (e.g. drawing applications).
-
31 May 2012 9:45 AM #3
Definitely listening. The gains will be proportional to the number of calls to Ext.Object.chain which is few since we don't use it many cases. The change is still a good suggestion though and makes perfect sense.
You could hook Ext.Object.chain and count the calls to see if I am correct on that
Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
31 May 2012 10:31 AM #4
The count is 968 times when my application starts. I'm not sure if this number is small or not so small, but thank you for listening

EDIT
847 - when this page loads
http://localhost/wag/js/extjs-4.1.0/examples/index.html
-
6 Oct 2012 10:58 AM #5
Here is my lightly tested solution. I just added the if statement that delegates to Object.create. I think this is all we need to do.
Code:Ext.Object.chain = function(object) { if (Object.create) { return Object.create(object); } TemplateClass.prototype = object; var result = new TemplateClass(); TemplateClass.prototype = null; return result; } // Test Ext.Object.chain({key: 'value'});
-
3 Jan 2013 7:05 PM #6
How about?
Code:Ext.Object.chain = Object.create || function (object) { TemplateClass.prototype = object; var result = new TemplateClass(); TemplateClass.prototype = null; return result; }Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-8087
in
4.2.0.265.


Reply With Quote