james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [09/24] james-project git commit: JAMES-2366 Use Optional for computing mapping size
Date Fri, 20 Apr 2018 02:12:54 GMT
JAMES-2366 Use Optional for computing mapping size

It avoids variable reallocation


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/57fa4c48
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/57fa4c48
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/57fa4c48

Branch: refs/heads/master
Commit: 57fa4c48418a3cf617b8921187e21fa942c4e4ae
Parents: 2001f8c
Author: benwa <btellier@linagora.com>
Authored: Fri Apr 6 09:52:34 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Thu Apr 19 11:12:07 2018 +0700

----------------------------------------------------------------------
 .../apache/james/rrt/lib/AbstractRecipientRewriteTable.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/57fa4c48/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
index bb82a8e..873a9d4 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
@@ -302,12 +302,12 @@ public abstract class AbstractRecipientRewriteTable implements RecipientRewriteT
 
     @Override
     public Map<String, Mappings> getAllMappings() throws RecipientRewriteTableException
{
-        int count = 0;
         Map<String, Mappings> mappings = getAllMappingsInternal();
 
-        if (mappings != null) {
-            count = mappings.size();
-        }
+        int count = Optional.ofNullable(mappings)
+            .map(Map::size)
+            .orElse(0);
+
         LOGGER.debug("Retrieve all mappings. Mapping count: {}", count);
         return mappings;
     }


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


Mime
View raw message