RFR: 8314569: (fs) Improve normalization of UnixPath for directories

Alan Bateman alanb at openjdk.org
Sat Aug 19 19:16:25 UTC 2023


On Fri, 18 Aug 2023 15:05:05 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> How often is the only  normalization the removal of a trailing "/"? It seems quite likely.
>> If that's the only normalization, then can the `normalize` call at line 94 could be replaced with a simple `substring(0, n-1)`.
>> It would save the string buffer creation and copying.
>> This is pretty carefully written code so it needs a thorough review.
>
>> How often is the only normalization the removal of a trailing "/"? It seems quite likely.
>> If that's the only normalization, then can the `normalize` call at line 94 could be replaced with a simple `substring(0, n-1)`.
>> It would save the string buffer creation and copying.
>> This is pretty carefully written code so it needs a thorough review.
> 
> The most common case is probably no duplicate or trailing slash, in which case this code won't be executed. The next most common is probably the trailing slash case, in which I think you have a good point, just need to be careful not to break the "/" case.

> @AlanBateman isn't "/" case handled in lines 108-109?

I think Roger's suggestion means that the trailing case would be handled in normalizeAndCheck. There are many ways to do this, we just need to keep it maintainable.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15342#issuecomment-1685087212


More information about the nio-dev mailing list