commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fred...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/math NumberUtils.java
Date Tue, 23 Sep 2003 17:02:10 GMT
fredrik     2003/09/23 10:02:10

  Modified:    lang/src/java/org/apache/commons/lang/math NumberUtils.java
  Log:
  Improved performance if str is null.
  
  Revision  Changes    Path
  1.16      +7 -1      jakarta-commons/lang/src/java/org/apache/commons/lang/math/NumberUtils.java
  
  Index: NumberUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/math/NumberUtils.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- NumberUtils.java	23 Sep 2003 15:46:42 -0000	1.15
  +++ NumberUtils.java	23 Sep 2003 17:02:10 -0000	1.16
  @@ -204,6 +204,9 @@
        * @return the int represented by the string, or the default if conversion fails
        */
       public static int toInt(String str, int defaultValue) {
  +        if(str == null) {
  +            return defaultValue;
  +        }
           try {
               return Integer.parseInt(str);
           } catch (NumberFormatException nfe) {
  @@ -250,6 +253,9 @@
        * @since 2.1
        */
       public static long toLong(String str, long defaultValue) {
  +        if (str == null) {
  +            return defaultValue;
  +        }
           try {
               return Long.parseLong(str);
           } catch (NumberFormatException nfe) {
  
  
  

Mime
View raw message