SEC-223: Improve hashCode() performance.
This commit is contained in:
parent
57aee4e605
commit
36c096858d
|
@ -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…
Reference in New Issue