You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2013/06/13 13:55:21 UTC

[jira] [Assigned] (WICKET-5233) Component.getBehaviors() can be implemented slightly more efficiently

     [ https://issues.apache.org/jira/browse/WICKET-5233?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov reassigned WICKET-5233:
---------------------------------------

    Assignee: Martin Grigorov
    
> Component.getBehaviors() can be implemented slightly more efficiently
> ---------------------------------------------------------------------
>
>                 Key: WICKET-5233
>                 URL: https://issues.apache.org/jira/browse/WICKET-5233
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.8.0
>            Reporter: Ota Hauptmann
>            Assignee: Martin Grigorov
>            Priority: Trivial
>              Labels: perfomance
>
> Component.getBehaviors() is implemented as
> "return getBehaviors(Behavior.class);"
> but can be
> "return getBehaviors(null);"
> As mentioned in getBehaviors(Class type) documentation: "The type or null for all". The handling code in Behaviors.getBehaviors method is following:
> if (obj != null && obj instanceof Behavior)
> {
> 	if (type == null || type.isAssignableFrom(obj.getClass()))
> 	{
> 		subset.add((M)obj);
> 	}
> }
> When called with "null" parameter, only the first condition of inner "if" is tested. If called with Behavior.class, all conditions has to be evaluated and you call "obj instanceof Behavior" twice in fact (because "Behavior.class.isAssignableFrom(obj.getClass())" is equivalent to "obj instanceof Behavior").

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira