pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1785745 - /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/type1/Type1Lexer.java
Date Mon, 06 Mar 2017 19:24:32 GMT
Author: tilman
Date: Mon Mar  6 19:24:31 2017
New Revision: 1785745

URL: http://svn.apache.org/viewvc?rev=1785745&view=rev
Log:
PDFBOX-2852: use switch

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/type1/Type1Lexer.java

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/type1/Type1Lexer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/type1/Type1Lexer.java?rev=1785745&r1=1785744&r2=1785745&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/type1/Type1Lexer.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/type1/Type1Lexer.java Mon
Mar  6 19:24:31 2017
@@ -378,54 +378,50 @@ class Type1Lexer
             char c = getChar();
 
             // string context
-            if (c == '(')
+            switch (c)
             {
-                openParens++;
-                sb.append('(');
-            }
-            else if (c == ')')
-            {
-                if (openParens == 0)
-                {
-                    // end of string
-                    return new Token(sb.toString(), Token.STRING);
-                }
-                else
-                {
+                case '(':
+                    openParens++;
+                    sb.append('(');
+                    break;
+                case ')':
+                    if (openParens == 0)
+                    {
+                        // end of string
+                        return new Token(sb.toString(), Token.STRING);
+                    }
                     sb.append(')');
                     openParens--;
-                }
-            }
-            else if (c == '\\')
-            {
-                // escapes: \n \r \t \b \f \\ \( \)
-                char c1 = getChar();
-                switch (c1)
-                {
-                    case 'n':
-                    case 'r': sb.append("\n"); break;
-                    case 't': sb.append('\t'); break;
-                    case 'b': sb.append('\b'); break;
-                    case 'f': sb.append('\f'); break;
-                    case '\\': sb.append('\\'); break;
-                    case '(': sb.append('('); break;
-                    case ')': sb.append(')'); break;
-                }
-                // octal \ddd
-                if (Character.isDigit(c1))
-                {
-                    String num = String.valueOf(new char[] { c1, getChar(), getChar() });
-                    Integer code = Integer.parseInt(num, 8);
-                    sb.append((char)(int)code);
-                }
-            }
-            else if (c == '\r' || c == '\n')
-            {
-                sb.append("\n");
-            }
-            else
-            {
-                sb.append(c);
+                    break;
+                case '\\':
+                    // escapes: \n \r \t \b \f \\ \( \)
+                    char c1 = getChar();
+                    switch (c1)
+                    {
+                        case 'n':
+                        case 'r': sb.append("\n"); break;
+                        case 't': sb.append('\t'); break;
+                        case 'b': sb.append('\b'); break;
+                        case 'f': sb.append('\f'); break;
+                        case '\\': sb.append('\\'); break;
+                        case '(': sb.append('('); break;
+                        case ')': sb.append(')'); break;
+                    }   
+                    // octal \ddd
+                    if (Character.isDigit(c1))
+                    {
+                        String num = String.valueOf(new char[] { c1, getChar(), getChar()
});
+                        Integer code = Integer.parseInt(num, 8);
+                        sb.append((char)(int)code);
+                    }
+                    break;
+                case '\r':
+                case '\n':
+                    sb.append("\n");
+                    break;
+                default:
+                    sb.append(c);
+                    break;
             }
         }
         return null;



Mime
View raw message