You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2023/04/04 16:37:39 UTC

[GitHub] [accumulo] keith-turner commented on a diff in pull request #3276: Optimize internal data structures in Authorizations

keith-turner commented on code in PR #3276:
URL: https://github.com/apache/accumulo/pull/3276#discussion_r1157507174


##########
core/src/main/java/org/apache/accumulo/core/security/Authorizations.java:
##########
@@ -112,6 +112,8 @@ private void checkAuths() {
    */
   public Authorizations(Collection<byte[]> authorizations) {
     checkArgument(authorizations != null, "authorizations is null");
+    this.auths = new HashSet<>(authorizations.size());
+    this.authsList = new ArrayList<>(authorizations.size());

Review Comment:
   If it does not break anything, we may be able to add a further optimization for an incoming empty set.  I looked into the implemenation of List.of() and Set.of() and both seem to return a ref to a static immutable object, so that would avoid any internal object allocation for the empty case.
   
   ```suggestion
      if(authorizations.isEmpty()){
         this.auths = Set.of();
         this.authsList = List.of();
       } else {
         this.auths = new HashSet<>(authorizations.size());
         this.authsList = new ArrayList<>(authorizations.size());    
       }
   ```
   
   If we had a static method for creating auths objects then we could similarly avoid allocating the Authorizations object when the input is empty.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org