Skip to content

Commit

Permalink
Optimize privilege accumulation with parallel streams
Browse files Browse the repository at this point in the history
Performance has been improved for privilege accumulation in the User entity. This was achieved by replacing standard forEach loops with parallelStreams, increasing efficiency particularly with large sets of user roles and privileges.
  • Loading branch information
Gcolon021 committed Jul 8, 2024
1 parent c2d927c commit 0179725
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Set<Privilege> getTotalPrivilege(){
return null;

Set<Privilege> privileges = new HashSet<>();
roles.forEach(r -> privileges.addAll(r.getPrivileges()));
roles.parallelStream().forEach(r -> privileges.addAll(r.getPrivileges()));
return privileges;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public Set<Privilege> getPrivilegesByApplication(Application application){
return null;

Set<Privilege> privileges = new HashSet<>();
roles.forEach(r -> privileges.addAll(r.getPrivileges()
roles.parallelStream().forEach(r -> privileges.addAll(r.getPrivileges()
.stream()
.filter(p -> application.getUuid()
.equals((p.getApplication()==null)?
Expand Down

0 comments on commit 0179725

Please sign in to comment.