You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/12/10 02:30:17 UTC

[james-project] 14/27: [Refactoring] Avoid variable allocation in FetchCommandParser::getSectionType

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 56820c22fb28b5b84159bc82cf3e334cf13322a3
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 9 14:15:34 2019 +0700

    [Refactoring] Avoid variable allocation in FetchCommandParser::getSectionType
---
 .../imap/decode/parser/FetchCommandParser.java     | 38 +++++++++-------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java
index 9f4d33a..eaae520 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java
@@ -221,31 +221,23 @@ public class FetchCommandParser extends AbstractUidCommandParser {
     }
 
     private int getSectionType(FetchPartPathDecoder decoder) throws DecodingException {
-        final int specifier = decoder.getSpecifier();
-        final int sectionType;
+        int specifier = decoder.getSpecifier();
         switch (specifier) {
-        case FetchPartPathDecoder.CONTENT:
-            sectionType = BodyFetchElement.CONTENT;
-            break;
-        case FetchPartPathDecoder.HEADER:
-            sectionType = BodyFetchElement.HEADER;
-            break;
-        case FetchPartPathDecoder.HEADER_FIELDS:
-            sectionType = BodyFetchElement.HEADER_FIELDS;
-            break;
-        case FetchPartPathDecoder.HEADER_NOT_FIELDS:
-            sectionType = BodyFetchElement.HEADER_NOT_FIELDS;
-            break;
-        case FetchPartPathDecoder.MIME:
-            sectionType = BodyFetchElement.MIME;
-            break;
-        case FetchPartPathDecoder.TEXT:
-            sectionType = BodyFetchElement.TEXT;
-            break;
-        default:
-            throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Section type is unsupported.");
+            case FetchPartPathDecoder.CONTENT:
+                return BodyFetchElement.CONTENT;
+            case FetchPartPathDecoder.HEADER:
+                return BodyFetchElement.HEADER;
+            case FetchPartPathDecoder.HEADER_FIELDS:
+                return BodyFetchElement.HEADER_FIELDS;
+            case FetchPartPathDecoder.HEADER_NOT_FIELDS:
+                return BodyFetchElement.HEADER_NOT_FIELDS;
+            case FetchPartPathDecoder.MIME:
+                return BodyFetchElement.MIME;
+            case FetchPartPathDecoder.TEXT:
+                return BodyFetchElement.TEXT;
+            default:
+                throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Section type is unsupported.");
         }
-        return sectionType;
     }
 
     private String readWord(ImapRequestLineReader request, String terminator) throws DecodingException {


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