Guillaume,
thanks for testing this.... yes definitely want to have faster implementation... even if it is all protected by a check for .
I'm in two minds.... one part of me wants to revert to an approach that builds the StringBuffer as it parses the URI. I'm sure it can be done with less complex code..... the other part of me thinks I don't really care about clients that send .. in URIs, but back on the other hand I don't want ../../../.. to be used as a DOS attack vector on a server.
So now that we have a clean implementation, I think we should consider that a specification to use to create a faster impl (the previous version was so unclear it was not a specification).
I'm thinking that an initial pass through to count the number of "/" characters would be a good start. If the count is 0, we return. Otherwise allocate a fixed size array to hold the indexes of the start of each segment. Then another pass through the URI looking segments start values to set in the array plus checking for . and .. segments, which will then update the segment array.
The final sweep through the segment array to generate the final URI array.
So this could be done with the allocation of a single array and single StringBuffer, plus 2 iterations through the URI characters and 1 iteration through the segments.
cheers