I see and agree with what you did, I was just messing with you about using an extra
varable when your original post sited efficiency as a problem with the old code...
see below
>
> + case 1:
> + length -= i;
> + break;
> +
> + case 2:
> + char eol1 = eol.charAt(0);
> + char eol2 = eol.charAt(1);
> + for (int j = i-1; j >= 0; j--)
Why not just use i in the for loop? ie:
for( ; i > 0; i--)
As you see, I'm just messing with ya. Obviously, for large i, your code is more
efficient than all the substring creation. Although if i is small and s is large the
old code will probably use less memory. (it'll still do the wrong thing tho).
--
Patrick