tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: svn commit: r945231 - /tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java
Date Mon, 17 May 2010 17:14:41 GMT
On 17/05/2010 18:08, Mark Thomas wrote:
> On 17/05/2010 17:50, Konstantin Kolinko wrote:
>> I am a bit shivering looking at ([a++] != [b++]),
>> but I did minimal changes to fix the issue.
> 
> Understood. If I get a chance, I'll look to see if I can find an equally
> good alternative.

How about (diff to original file)

Index: java/org/apache/tomcat/util/buf/ByteChunk.java
===================================================================
--- java/org/apache/tomcat/util/buf/ByteChunk.java	(revision 945095)
+++ java/org/apache/tomcat/util/buf/ByteChunk.java	(working copy)
@@ -688,6 +688,9 @@
         for( int i=myOff+start; i <= (end - srcLen); i++ ) {
             if( buff[i] != first ) continue;
             // found first char, now look for a match
+            if (src.length() == 1) {
+                return i-start;
+            }
             int myPos=i+1;
             for( int srcPos=srcOff + 1; srcPos< srcEnd; ) {
                 if( buff[myPos++] != src.charAt( srcPos++ ))


Your test:
assertEquals(0, bc.indexOf("wo", 0, 1, 0));

fails but given "wo".length != 1 then I'm not sure that is an issue.

Mark



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


Mime
View raw message