List Info

Thread: svn commit: r438081 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java




svn commit: r438081 - /ant/core/trunk/src/main/org/apache/tool s/ant/taskdefs/ManifestClassPath.java
user name
2006-08-29 14:43:57
Author: mbenson
Date: Tue Aug 29 07:43:54 2006
New Revision: 438081

URL: 
http://svn.apache.org/viewvc?rev=438081&view=rev
Log:
moved space append so that final deletion is unnecessary.
Minor javadoc and formatting changes.

Modified:
   
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manife
stClassPath.java

Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manife
stClassPath.java
URL: http://svn.apa
che.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/
taskdefs/ManifestClassPath.java?rev=438081&r1=438080&
;r2=438081&view=diff
============================================================
==================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manife
stClassPath.java (original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Manife
stClassPath.java Tue Aug 29 07:43:54 2006
 -1,5
+1,5 
 /*
- * Copyright  2005-2006 The Apache Software Foundation
+ * Copyright 2005-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the
"License");
  *  you may not use this file except in compliance with the
License.
 -32,8
+32,7 
  *
  * ant.task category="property"
  */
-public class ManifestClassPath
-             extends Task {
+public class ManifestClassPath extends Task {
 
     /** The property name to hold the classpath value. */
     private String _name;
 -48,7
+47,7 
     private Path _path;
 
     /**
-     * Sets a property, which must not already exists, with
a space
+     * Sets a property, which must not already exist, with
a space
      * separated list of files and directories relative to
the jar
      * file's parent directory.
      */
 -87,6
+86,9 
         StringBuffer buffer = new StringBuffer();
         StringBuffer element = new StringBuffer();
         for (int i = 0; i < elements.length; ++i) {
+            if (i > 0) {
+                buffer.append(' ');
+            }
             // Normalize the current file
             File pathEntry = new File(elements[i]);
             pathEntry =
fileUtils.normalize(pathEntry.getAbsolutePath());
 -134,12
+136,6 
                 throw new BuildException(exc);
             }
             buffer.append(relPath);
-            buffer.append(' ');
-        }
-        
-        // Get rid of trailing space, if any
-        if (buffer.length() > 0) {
-            buffer.setLength(buffer.length() - 1);
         }
 
         // Finally assign the property with the manifest
classpath
 -157,7
+153,7 
 
     /**
      * The JAR file to contain the classpath attribute in
its manifest.
-     * 
+     *
      * param  jarfile the JAR file. Need not exist yet, but
its parent
      *         directory must exist on the other hand.
      */



------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeant.apache.org
For additional commands, e-mail: dev-helpant.apache.org

svn commit: r438081 - /ant/core/trunk/src/main/org/apache/tool s/ant/taskdefs/ManifestClassPath.java
user name
2006-08-29 17:49:43
On 8/29/06, mbensonapache.org <mbensonapache.org> wrote:
> moved space append so that final deletion is
unnecessary.
> Minor javadoc and formatting changes.
>
>         for (int i = 0; i < elements.length; ++i) {
> +            if (i > 0) {
> +                buffer.append(' ');
> +            } ...
>             buffer.append(relPath);
> -            buffer.append(' ');
> -        }
> -
> -        // Get rid of trailing space, if any
> -        if (buffer.length() > 0) {
> -            buffer.setLength(buffer.length() - 1);
>         }

I actually prefer my version Matt. Adding a test for all
loop
iterations to special case the first iteration always seemed
not right
to me. I prefer to remove the space unconditionally added,
which is
lightweight on a string buffer, than adding the test,
especially when
elements.length becomes large. A matter of taste I guess.
--DD

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeant.apache.org
For additional commands, e-mail: dev-helpant.apache.org

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )