This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 317bf5c21d48638ae0500939e233db87c77c94c8
Author: Benoit Tellier <[email protected]>
AuthorDate: Fri Mar 11 09:22:44 2022 +0700

    [PERF] SelectedMailboxImpl: avoid needless copies
    
    Copy a treeset into a treeset then make it non-modifiable...
---
 .../org/apache/james/imap/processor/base/SelectedMailboxImpl.java | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index 077d93d..2b3aa92 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -26,7 +26,6 @@ import static io.vavr.Predicates.instanceOf;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
@@ -63,6 +62,7 @@ import org.apache.james.mailbox.model.UpdatedFlags;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSortedSet;
 
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
@@ -338,8 +338,7 @@ public class SelectedMailboxImpl implements 
SelectedMailbox, EventListener {
         // copy the TreeSet to fix possible
         // java.util.ConcurrentModificationException
         // See IMAP-278
-        return Collections.unmodifiableSet(new TreeSet<>(flagUpdateUids));
-        
+        return ImmutableSortedSet.copyOf(flagUpdateUids);
     }
 
     @Override
@@ -347,8 +346,7 @@ public class SelectedMailboxImpl implements 
SelectedMailbox, EventListener {
         // copy the TreeSet to fix possible
         // java.util.ConcurrentModificationException
         // See IMAP-278
-        return Collections.unmodifiableSet(new TreeSet<>(expungedUids));
-        
+        return ImmutableSortedSet.copyOf(expungedUids);
     }
 
     @Override

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to