From 444756839ca789f5f599830849d9e0531328841c Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Sun, 5 Oct 2014 12:08:55 +0100 Subject: [PATCH] EnumSet is more efficient than HashSet --- src/com/fsck/k9/mail/Message.java | 5 +++-- src/com/fsck/k9/mail/store/ImapStore.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/mail/Message.java b/src/com/fsck/k9/mail/Message.java index ce1a59711..d09c7b1a3 100644 --- a/src/com/fsck/k9/mail/Message.java +++ b/src/com/fsck/k9/mail/Message.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.EnumSet; import java.util.HashSet; import java.util.Set; @@ -27,7 +28,7 @@ public abstract class Message implements Part, CompositeBody { protected String mUid; - private Set mFlags = new HashSet(); + private Set mFlags = EnumSet.noneOf(Flag.class); private Date mInternalDate; @@ -291,7 +292,7 @@ public abstract class Message implements Part, CompositeBody { destination.mReference = mReference; // mFlags contents can change during the object lifetime, so copy the Set - destination.mFlags = new HashSet(mFlags); + destination.mFlags = EnumSet.copyOf(mFlags); } /** diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index 291f1d768..acfe04aa2 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -30,6 +30,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Deque; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -116,7 +117,7 @@ public class ImapStore extends Store { private static int FETCH_WINDOW_SIZE = 100; - private Set mPermanentFlagsIndex = new HashSet(); + private Set mPermanentFlagsIndex = EnumSet.noneOf(Flag.class); private static final String CAPABILITY_IDLE = "IDLE"; private static final String CAPABILITY_AUTH_CRAM_MD5 = "AUTH=CRAM-MD5";