findChar is inconsistent in that it only supports characters in the range 0-127 while...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 17 May 2010 08:26:43 +0000 (08:26 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 17 May 2010 08:26:43 +0000 (08:26 +0000)
It isn't used within the Tomcat codebase. Make it's behaviour consistent with the other character search methods.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@945016 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/buf/ByteChunk.java

index 912685d..5a1d482 100644 (file)
@@ -778,7 +778,7 @@ public final class ByteChunk implements Cloneable, Serializable {
      * Returns the first instance of the given character in the given byte array
      * between the specified start and end.
      * <br/>
-     * NOTE: This only works for characters in the range 0-127.
+     * NOTE: This only works for single byte characters.
      * 
      * @param bytes The byte array to search
      * @param start The point to start searching from in the byte array
@@ -788,15 +788,7 @@ public final class ByteChunk implements Cloneable, Serializable {
      *                  if the character is not found.
      */
     public static int findChar(byte bytes[], int start, int end, char c) {
-        byte b = (byte)c;
-        int offset = start;
-        while (offset < end) {
-            if (bytes[offset] == b) {
-                return offset;
-            }
-            offset++;
-        }
-        return -1;
+        return indexOf(bytes, start, end, c);
     }
 
     /**