You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/06/26 05:06:22 UTC

[james-project] 04/06: [PERFORMANCE] MessageViewFactory::hasOnlyOneMessageId shortcut on single value

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 1636eca5a2010bd7244641f1cbd94a2e1b6e757f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 21 14:48:48 2021 +0700

    [PERFORMANCE] MessageViewFactory::hasOnlyOneMessageId shortcut on single value
    
    This takes 0.20% of CPU and represents 0.34% of memory allocation...
---
 .../apache/james/jmap/draft/model/message/view/MessageViewFactory.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageViewFactory.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageViewFactory.java
index a720019..3333bca 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageViewFactory.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageViewFactory.java
@@ -80,6 +80,9 @@ public interface MessageViewFactory<T extends MessageView> {
         }
 
         private static boolean hasOnlyOneMessageId(Collection<MessageResult> messageResults) {
+            if (messageResults.size() == 1) {
+                return true;
+            }
             return messageResults
                 .stream()
                 .map(MessageResult::getMessageId)

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org