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

Sergey Tsypanov stsypanov at openjdk.org
Sat Aug 19 05:54:29 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?

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

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


More information about the nio-dev mailing list