Attached.

Alan F. Gates
Software Engineer
Radik Software
Index: PathConvert.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
retrieving revision 1.5
diff -u -r1.5 PathConvert.java
--- PathConvert.java    2001/11/30 17:35:06     1.5
+++ PathConvert.java    2001/12/03 21:26:19
@@ -254,7 +254,6 @@
 
         // Determine the from/to char mappings for dir sep
         char fromDirSep = onWindows ? '\\' : '/';
-        char toDirSep   = dirSep.charAt(0);
 
         StringBuffer rslt = new StringBuffer( 100 );
 
@@ -268,8 +267,22 @@
 
             // Now convert the path and file separator characters from the
             // current os to the target os.
-
-            elem = elem.replace( fromDirSep, toDirSep );
+            // Optimize for most likely case
+            if (dirSep.length() == 1) {
+                char toDirSep   = dirSep.charAt(0);
+                elem = elem.replace( fromDirSep, toDirSep );
+            } else {
+                StringBuffer s = new StringBuffer();
+                for (int j = 0; j < elem.length(); j++) {
+                    char c = elem.charAt(j);
+                    if (c == fromDirSep) {
+                        s.append(dirSep);
+                    } else {
+                        s.append(c);
+                    }
+                }
+                elem = s.toString();
+            }
 
             if( i != 0 ) rslt.append( pathSep );
             rslt.append( elem );

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to