ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/nativelib Environment.java
Date Sat, 26 Jan 2002 11:57:54 GMT
donaldp     02/01/26 03:57:54

  Modified:    proposal/myrmidon/src/java/org/apache/aut/nativelib
                        Environment.java
  Log:
  Use StringBuffer in inner loop rather than string
  
  Removing a Audit violation
  
  Revision  Changes    Path
  1.3       +11 -17    jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/nativelib/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/nativelib/Environment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Environment.java	20 Jan 2002 17:32:58 -0000	1.2
  +++ Environment.java	26 Jan 2002 11:57:53 -0000	1.3
  @@ -24,7 +24,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:thomas.haas@softwired-inc.com">Thomas Haas</a>
  - * @version $Revision: 1.2 $ $Date: 2002/01/20 17:32:58 $
  + * @version $Revision: 1.3 $ $Date: 2002/01/26 11:57:53 $
    */
   public final class Environment
   {
  @@ -100,38 +100,32 @@
   
           final Properties properties = new Properties();
           final BufferedReader in = new BufferedReader( new StringReader( data ) );
  -        String var = null;
  +        final StringBuffer var = new StringBuffer();
           String line;
  -        while( ( line = in.readLine() ) != null )
  +        while( null != ( line = in.readLine() ) )
           {
  -            if( line.indexOf( '=' ) == -1 )
  +            if( -1 == line.indexOf( '=' ) )
               {
                   // Chunk part of previous env var (UNIX env vars can
                   // contain embedded new lines).
  -                if( var == null )
  -                {
  -                    var = StringUtil.LINE_SEPARATOR + line;
  -                }
  -                else
  -                {
  -                    var += StringUtil.LINE_SEPARATOR + line;
  -                }
  +                var.append( StringUtil.LINE_SEPARATOR );
               }
               else
               {
                   // New env var...append the previous one if we have it.
  -                if( var != null )
  +                if( 0 != var.length() )
                   {
  -                    addProperty( properties, var );
  +                    addProperty( properties, var.toString() );
  +                    var.setLength( 0 );
                   }
  -                var = line;
               }
  +            var.append( line );
           }
   
           // Since we "look ahead" before adding, there's one last env var.
  -        if( null != var )
  +        if( 0 != var.length() )
           {
  -            addProperty( properties, var );
  +            addProperty( properties, var.toString() );
           }
           return properties;
       }
  
  
  

--
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