From: markt Date: Sun, 16 May 2010 21:31:57 +0000 (+0000) Subject: Code clean-up X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=807974005d6e76ed6b133b64ffe0d39ca6a81466;p=tomcat7.0 Code clean-up git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@944918 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java index 6935fa115..c11559f0e 100644 --- a/java/org/apache/tomcat/util/buf/ByteChunk.java +++ b/java/org/apache/tomcat/util/buf/ByteChunk.java @@ -64,6 +64,8 @@ import java.io.Serializable; */ public final class ByteChunk implements Cloneable, Serializable { + private static final long serialVersionUID = 1L; + /** Input interface, used when the buffer is empty * * Same as java.nio.channel.ReadableByteChannel @@ -119,6 +121,7 @@ public final class ByteChunk implements Cloneable, Serializable { * Creates a new, uninitialized ByteChunk object. */ public ByteChunk() { + // NO-OP } public ByteChunk( int initial ) { @@ -735,30 +738,29 @@ public final class ByteChunk implements Cloneable, Serializable { * @param starting The start position */ public int indexOf(char c, int starting) { - int ret = indexOf( buff, start+starting, end, c); + int ret = indexOf(buff, start+starting, end, c); return (ret >= start) ? ret - start : -1; } - public static int indexOf( byte bytes[], int off, int end, char qq ) - { - // Works only for UTF - while( off < end ) { - byte b=bytes[off]; - if( b==qq ) - return off; - off++; - } - return -1; + /** + * Find a character, no side effects. Only works for single-byte character + * sets. + * @return index of char if found, -1 if not + */ + public static int indexOf(byte bytes[], int start, int end, char c) { + return findChar(bytes, start, end, c); } - /** Find a character, no side effects. - * @return index of char if found, -1 if not + /** + * Find a character, no side effects. Only works for single-byte character + * sets. + * @return index of char if found, -1 if not */ - public static int findChar( byte buf[], int start, int end, char c ) { - byte b=(byte)c; + public static int findChar( byte buf[], int start, int end, char c) { + // Works only for single byte character sets int offset = start; while (offset < end) { - if (buf[offset] == b) { + if (buf[offset] == c) { return offset; } offset++; @@ -766,8 +768,10 @@ public final class ByteChunk implements Cloneable, Serializable { return -1; } - /** Find a character, no side effects. - * @return index of char if found, -1 if not + /** + * Find any one of an array of characters. No side effects. Only works for + * single-byte character sets. + * @return index of char if found, -1 if not */ public static int findChars( byte buf[], int start, int end, byte c[] ) { int clen=c.length; @@ -782,15 +786,15 @@ public final class ByteChunk implements Cloneable, Serializable { return -1; } - /** Find the first character != c - * @return index of char if found, -1 if not + /** + * Find the first character not in an array of characters. No side effects. + * Only works for single-byte character sets. + * @return index of char if found, -1 if not */ - public static int findNotChars( byte buf[], int start, int end, byte c[] ) - { + public static int findNotChars(byte buf[], int start, int end, byte c[]) { int clen=c.length; int offset = start; boolean found; - while (offset < end) { found=true; for( int i=0; i