Browse Source

SEC-223: Improve hashCode() performance.

1.0.x
Ben Alex 20 years ago
parent
commit
36c096858d
  1. 10
      core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java

10
core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java

@ -146,10 +146,12 @@ public abstract class AbstractAuthenticationToken implements Authentication { @@ -146,10 +146,12 @@ public abstract class AbstractAuthenticationToken implements Authentication {
public int hashCode() {
int code = 31;
if (this.getAuthorities() != null) {
for (int i = 0; i < this.getAuthorities().length; i++) {
code ^= this.getAuthorities()[i].hashCode();
// Copy authorities to local variable for performance (SEC-223)
GrantedAuthority[] authorities = this.getAuthorities();
if (authorities != null) {
for (int i = 0; i < authorities.length; i++) {
code ^= authorities[i].hashCode();
}
}

Loading…
Cancel
Save