Skip to content

Commit

Permalink
Save hashCode locally for performance gain
Browse files Browse the repository at this point in the history
  • Loading branch information
Ståle Pedersen authored and pmuir committed Nov 16, 2010
1 parent 9a3d972 commit a6a2aba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion impl/src/main/java/org/jboss/weld/bean/RIBean.java
Expand Up @@ -44,11 +44,14 @@ public abstract class RIBean<T> implements Bean<T>, PassivationCapable
private final BeanManagerImpl beanManager;

private final String id;

private final int hashCode;

protected RIBean(String idSuffix, BeanManagerImpl beanManager)
{
this.beanManager = beanManager;
this.id = new StringBuilder().append(BEAN_ID_PREFIX).append(BEAN_ID_SEPARATOR).append(beanManager.getId()).append(BEAN_ID_SEPARATOR).append(idSuffix).toString();
this.hashCode = this.id.hashCode();
}

protected BeanManagerImpl getBeanManager()
Expand Down Expand Up @@ -124,7 +127,7 @@ public boolean equals(Object obj)
@Override
public int hashCode()
{
return getId().hashCode();
return hashCode;
}

public String getId()
Expand Down

0 comments on commit a6a2aba

Please sign in to comment.