krypton-io
krypton-io

Reputation: 713

component.query versus component.getcomponent in performance

is component.query() faster than component.getComponent() ?

what are the pros and cons of using component.query ?

Upvotes: 2

Views: 371

Answers (1)

sra
sra

Reputation: 23973

While Ext.ComponentQuery queries for all underlying Components (you may define a traversing start as second param after the query string) it also allow you to query by a various set of params, attributes, pseudo classes, functions, etc. Full Reference and always result in a set (array) compinstance.GetComponent('itemId') only queries the direct childs of the calling component for the itemId property and will always return one reference or null. Note that the itemId need only to be unique to all it's siblings.

So yes GetComponent() will be a bit faster.

I don't think that there are huge pros and cons. GetComponent() cannot be used that often because you may not only looking in level. Take a menu which groups the the buttons, GetComponent() will only find the group but not the anything within it. So don't care to much about it.

Upvotes: 2

Related Questions