ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util ChainReaderHelper.java
Date Thu, 28 Feb 2002 19:48:50 GMT
umagesh     02/02/28 11:48:50

  Modified:    proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util
                        ChainReaderHelper.java
  Log:
  Use StringBuffer to assemble String.
  
  Revision  Changes    Path
  1.3       +8 -3      jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
  
  Index: ChainReaderHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ChainReaderHelper.java	28 Feb 2002 19:43:01 -0000	1.2
  +++ ChainReaderHelper.java	28 Feb 2002 19:48:50 -0000	1.3
  @@ -211,15 +211,20 @@
           final char[] buffer = new char[bufferSize];
           int bufferLength = 0;
           String text = null;
  +        StringBuffer textBuffer = null;
           while (bufferLength != -1) {
               bufferLength = rdr.read(buffer);
               if (bufferLength != -1) {
  -                if (text == null) {
  -                    text = new String(buffer, 0, bufferLength);
  +                if (textBuffer == null) {
  +                    textBuffer = new StringBuffer(
  +                                    new String(buffer, 0, bufferLength));
                   } else {
  -                    text += new String(buffer, 0, bufferLength);
  +                    textBuffer.append(new String(buffer, 0, bufferLength));
                   }
               }
  +        }
  +        if (textBuffer != null) {
  +            text = textBuffer.toString();
           }
           return text;
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message