Author: lehmi
Date: Wed Sep 14 18:53:35 2011
New Revision: 1170768

URL: http://svn.apache.org/viewvc?rev=1170768&view=rev
Log:
PDFBOX-1080: minor performance improvements as proposed by Lars Torunski

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java?rev=1170768&r1=1170767&r2=1170768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java Wed 
Sep 14 18:53:35 2011
@@ -90,7 +90,8 @@ public class ICU4JImpl 
             char c = str.charAt(q);
             if ((0xFB00 <= c && c <= 0xFDFF) || (0xFE70 <= c && c <= 0xFEFF))
             {
-                if (builder == null) {
+                if (builder == null) 
+                {
                     builder = new StringBuilder(strLength * 2);
                 }
                 builder.append(str.substring(p, q));
@@ -111,9 +112,12 @@ public class ICU4JImpl 
                 p = q + 1;
             }
         }
-        if (builder == null) {
+        if (builder == null) 
+        {
             return str;
-        } else {
+        } 
+        else 
+        {
             builder.append(str.substring(p, q));
             return builder.toString();
         }
@@ -132,9 +136,10 @@ public class ICU4JImpl 
         for (int i = 0; i < strLength; i++) 
         {
             char c = str.charAt(i);
-            if(Character.getType(c) == Character.NON_SPACING_MARK 
-                    || Character.getType(c) == Character.MODIFIER_SYMBOL
-                    || Character.getType(c) == Character.MODIFIER_LETTER)
+            int type = Character.getType(c);
+            if(type == Character.NON_SPACING_MARK 
+                    || type == Character.MODIFIER_SYMBOL
+                    || type == Character.MODIFIER_LETTER)
             {
                 /*
                  * Trim because some decompositions have an extra space, such 
as

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java?rev=1170768&r1=1170767&r2=1170768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TextPosition.java 
Wed Sep 14 18:53:35 2011
@@ -116,8 +116,8 @@ public class TextPosition
      * Constructor.
      *
      * @param pageRotation rotation of the page that the text is located in
-     * @param pageWidth rotation of the page that the text is located in
-     * @param pageHeight rotation of the page that the text is located in
+     * @param pageWidthValue rotation of the page that the text is located in
+     * @param pageHeightValue rotation of the page that the text is located in
      * @param textPositionSt TextMatrix for start of text (in display units)
      * @param textPositionEnd TextMatrix for end of text (in display units)
      * @param maxFontH Maximum height of text (in display units)
@@ -128,12 +128,13 @@ public class TextPosition
      * @param fontSizeValue The new font size.
      * @param fontSizeInPt The font size in pt units.
      *
-     * @deprecated Use {@link TextPosition(int, float, float, Matrix, float, 
float, float, float, float, String, PDFont, float, int)} instead.
+     * @deprecated Use {@link TextPosition(int, float, float, Matrix, float, 
float, float, float, float, 
+     * String, PDFont, float, int)} instead.
      */
     public TextPosition(
             int pageRotation,
-            float pageWidth,
-            float pageHeight,
+            float pageWidthValue,
+            float pageHeightValue,
             Matrix textPositionSt,
             Matrix textPositionEnd,
             float maxFontH,
@@ -145,7 +146,7 @@ public class TextPosition
             int fontSizeInPt
     )
     {
-        this(pageRotation, pageWidth, pageHeight, textPositionSt,
+        this(pageRotation, pageWidthValue, pageHeightValue, textPositionSt,
                 textPositionEnd.getXPosition(), textPositionEnd.getYPosition(),
                 maxFontH, individualWidth, spaceWidth, string, currentFont, 
fontSizeValue, fontSizeInPt);
     }
@@ -154,11 +155,11 @@ public class TextPosition
      * Constructor.
      *
      * @param pageRotation rotation of the page that the text is located in
-     * @param pageWidth rotation of the page that the text is located in
-     * @param pageHeight rotation of the page that the text is located in
+     * @param pageWidthValue rotation of the page that the text is located in
+     * @param pageHeightValue rotation of the page that the text is located in
      * @param textPositionSt TextMatrix for start of text (in display units)
-     * @param endX
-     * @param endY
+     * @param endXValue x coordinate of the end position
+     * @param endYValue y coordinate of the end position
      * @param maxFontH Maximum height of text (in display units)
      * @param individualWidth The width of the given character/string. (in ? 
units)
      * @param spaceWidth The width of the space character. (in display units)
@@ -169,11 +170,11 @@ public class TextPosition
      */
     public TextPosition(
             int pageRotation,
-            float pageWidth,
-            float pageHeight,
+            float pageWidthValue,
+            float pageHeightValue,
             Matrix textPositionSt,
-            float endX,
-            float endY,
+            float endXValue,
+            float endYValue,
             float maxFontH,
             float individualWidth,
             float spaceWidth,
@@ -185,8 +186,8 @@ public class TextPosition
     {
         this.textPos = textPositionSt;
 
-        this.endX = endX;
-        this.endY = endY;
+        this.endX = endXValue;
+        this.endY = endYValue;
 
         this.rot = pageRotation;
         // make sure it is 0 to 270 and no negative numbers
@@ -196,8 +197,8 @@ public class TextPosition
         }
 
         this.maxTextHeight = maxFontH;
-        this.pageHeight = pageHeight;
-        this.pageWidth = pageWidth;
+        this.pageHeight = pageHeightValue;
+        this.pageWidth = pageWidthValue;
 
         this.widths = new float[]{individualWidth};
         this.widthOfSpace = spaceWidth;
@@ -739,9 +740,14 @@ public class TextPosition
      */
     public boolean isDiacritic()
     {
-        String cText = this.getCharacter();
-        return (cText.length() == 1 &&  (Character.getType(cText.charAt(0)) == 
Character.NON_SPACING_MARK
-                || Character.getType(cText.charAt(0)) == 
Character.MODIFIER_SYMBOL
-                || Character.getType(cText.charAt(0)) == 
Character.MODIFIER_LETTER));
+        final String cText = this.getCharacter(); 
+        if (cText.length() != 1)
+        {
+            return false; 
+        }
+        final int type = Character.getType(cText.charAt(0)); 
+        return (type == Character.NON_SPACING_MARK 
+                || type == Character.MODIFIER_SYMBOL 
+                || type == Character.MODIFIER_LETTER); 
     }
 }
\ No newline at end of file


Reply via email to