mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-26 05:42:31 +00:00
SEC-223: Improve hashCode() performance.
This commit is contained in:
parent
57aee4e605
commit
36c096858d
@ -147,9 +147,11 @@ public abstract class AbstractAuthenticationToken implements Authentication {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int code = 31;
|
int code = 31;
|
||||||
|
|
||||||
if (this.getAuthorities() != null) {
|
// Copy authorities to local variable for performance (SEC-223)
|
||||||
for (int i = 0; i < this.getAuthorities().length; i++) {
|
GrantedAuthority[] authorities = this.getAuthorities();
|
||||||
code ^= this.getAuthorities()[i].hashCode();
|
if (authorities != null) {
|
||||||
|
for (int i = 0; i < authorities.length; i++) {
|
||||||
|
code ^= authorities[i].hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user