Hi,

I was looking around when all of the sudden I saw some methods that
were essentially replacing all occurances of a character with another
character.  They had custom code, instead of simply using the
String.replace() method.  That's the patch, replaced a lot of lines of
code with the .replace() calls.

have a look

fern

Index: 
src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java,v
retrieving revision 1.2
diff -u -r1.2 ClassFileUtils.java
--- src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java  
2001/01/03 14:18:36     1.2
+++ src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java  
2001/02/27 06:10:17
@@ -73,30 +73,10 @@
      * @return the class name in dot notation (eg. java.lang.Object).
      */
     static public String convertSlashName(String name) {
-        String dotName = null;
-        int    startIndex = 0;
-        int    sepIndex = 0;
 
-        String slashName = name.replace('\\', '/');
-        do {
-            String component = null;
+       String slashName = name.replace( '\\', '/' );   // normalization
+       String dotName = slashName.replace( '/', '.' ); // dot-tification
 
-            sepIndex = slashName.indexOf('/', startIndex);
-
-            if (sepIndex == -1) {
-                component = slashName.substring(startIndex);
-            } else {
-                component = slashName.substring(startIndex, sepIndex);
-                startIndex = sepIndex + 1;
-            } 
-
-            if (dotName == null) {
-                dotName = component;
-            } else {
-                dotName += "." + component;
-            } 
-        } while (sepIndex != -1);
-
         return dotName;
     } 
 
@@ -108,28 +88,8 @@
      * @return the class name in slash notation (eg. java/lang/Object).
      */
     static public String convertDotName(String dotName) {
-        String slashName = null;
-        int    startIndex = 0;
-        int    sepIndex = 0;
-
-        do {
-            String component = null;
-
-            sepIndex = dotName.indexOf('.', startIndex);
-
-            if (sepIndex == -1) {
-                component = dotName.substring(startIndex);
-            } else {
-                component = dotName.substring(startIndex, sepIndex);
-                startIndex = sepIndex + 1;
-            } 
 
-            if (slashName == null) {
-                slashName = component;
-            } else {
-                slashName += "/" + component;
-            } 
-        } while (sepIndex != -1);
+       String slashName = dotName.replace( '.', '/');   // slash-ification
 
         return slashName;
     } 

Reply via email to