You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Ota Hauptmann (JIRA)" <ji...@apache.org> on 2013/06/13 13:37:20 UTC
[jira] [Created] (WICKET-5233) Component.getBehaviors() can be
implemented slightly more efficiently
Ota Hauptmann created WICKET-5233:
-------------------------------------
Summary: 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
Priority: Trivial
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