DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17955>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17955

Unnecessary exception throwing.

           Summary: Unnecessary exception throwing.
           Product: Fop
           Version: 0.20.5
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: general
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


In FontInfo the method parseInt is used to figure out if weight is a number or 
not, and if its not an exception is thrown. Its a bit nicer to look at the 
first char and then decide if it got a chance to be a number.
And I belive that its far more common to specify the weight with 'normal' 
or 'bold' then a number, so there are some cpu-time to save...

Index: FontInfo.java
===================================================================
RCS file: /home/cvspublic/xml-
fop/src/org/apache/fop/layout/Attic/FontInfo.java,v
retrieving revision 1.12.2.4
diff -u -r1.12.2.4 FontInfo.java
--- FontInfo.java       25 Feb 2003 14:07:03 -0000      1.12.2.4
+++ FontInfo.java       13 Mar 2003 13:21:40 -0000
@@ -124,13 +124,16 @@
      */
     public static String createFontKey(String family, String style,
                                        String weight) {
-        int i;
+               int i = 0;
 
-        try {
-            i = Integer.parseInt(weight);
-        } catch (NumberFormatException e) {
-            i = 0;
-        }
+               char c = weight.charAt(0);
+               if (c >= '0' && c <= '9') {
+                       try {
+                               i = Integer.parseInt(weight);
+                       } catch (NumberFormatException e) {
+                               i = 0;
+                       }
+               }
 
         if (i > 600)
             weight = "bold";

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to