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: [email protected]
For additional commands, e-mail: [email protected]