ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <anto...@gmx.de>
Subject Re: svn commit: r393996 - /ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
Date Fri, 14 Apr 2006 12:44:53 GMT
Martijn Kruithof wrote:
> Hi,
>
> I think the while construct is cleaner and more readable, and do not
> see any real benefit of this code change.
> Especially against using the for loop is that when using the for loop
> the step of the loop should take place in the third part of the for,
> and not somewhere inside the for loop.
>
> What's the position of other committers on this?
>
I also think that the code was more readable before. The variable
myTokenizer or tzr being a variable of a private function goes quickly
out of scope anyway.

Something like this would alleviate the remark of Martijn concerning
where the incrementation takes place but does not seem to be proper java
syntax.
for (StringTokenizer tzr = new StringTokenizer(path, File.pathSeparator)
&& String elementName = tzr.nextToken();
tzr.hasMoreElements();elementName = tzr.nextToken()) {

> Martijn
>
>
Antoine

> kevj@apache.org wrote:
>
>> Author: kevj
>> Date: Thu Apr 13 18:24:01 2006
>> New Revision: 393996
>>
>> URL: http://svn.apache.org/viewcvs?rev=393996&view=rev
>> Log:
>> slight tweak while -> for (reduce scope of variable to just loop)
>>
>> Modified:
>>    ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
>>
>> Modified:
>> ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
>> URL:
>> http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java?rev=393996&r1=393995&r2=393996&view=diff
>>
>> ==============================================================================
>>
>> --- ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
>> (original)
>> +++ ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
>> Thu Apr 13 18:24:01 2006
>> @@ -114,10 +114,9 @@
>>      */
>>     private void addPath(String path, boolean getJars, List libPathURLs)
>>             throws MalformedURLException {
>> -        StringTokenizer myTokenizer
>> -            = new StringTokenizer(path, File.pathSeparator);
>> -        while (myTokenizer.hasMoreElements()) {
>> -            String elementName = myTokenizer.nextToken();
>> +        for (StringTokenizer tzr = new StringTokenizer(path,
>> File.pathSeparator); +                tzr.hasMoreElements();) {
>> +            String elementName = tzr.nextToken();
>>             File element = new File(elementName);
>>             if (elementName.indexOf("%") != -1 && !element.exists()) {
>>                 continue;
>>
>>
>>


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


Mime
View raw message