commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Feldhacker" <feldhacker.ch...@mchsi.com>
Subject [lang] [patch] CharRange utilizing StringBuffer
Date Sat, 02 Aug 2003 05:54:11 GMT
[my first real post:]
CharRange.toString() method was modified to utilize a StringBuffer.


Index: CharRange.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/CharRa
nge.java,v
retrieving revision 1.8
diff -u -r1.8 CharRange.java
--- CharRange.java 26 Jul 2003 15:33:34 -0000 1.8
+++ CharRange.java 2 Aug 2003 05:43:11 -0000
@@ -195,16 +195,16 @@
      * @return string representation
      */
     public String toString() {
-        String str = "";
+        StringBuffer buff = new StringBuffer(4);
         if( isNegated() ) {
-            str += "^";
+            buff.append('^');
         }
-        str += start;
+        buff.append(start);
         if( isRange() ) {
-            str += "-";
-            str += close;
+            buff.append('-');
+            buff.append(close);
         }
-        return str;
+        return buff.toString();
     }

 }



Mime
View raw message