Code Review Request: 7168172: (fs) Files.isReadable slow on Windows

Kurchi Hazra kurchi.subhra.hazra at oracle.com
Fri Aug 24 11:00:11 PDT 2012


Thanks for the reviews. I'll integrate the comments and push this fix then.

- Kurchi


On 8/24/2012 4:00 AM, Ulf Zibis wrote:
>
> Am 23.08.2012 23:17, schrieb Kurchi Hazra:
>>
>> Here is an updated webrev: 
>> http://cr.openjdk.java.net/~khazra/7168172/webrev.01/
>>
>> I left the booleans as it is, but removed the modes.length() check.
>
> By error I had removed your former comment:
>    // default if modes not specified
>
> Maybe you better integrate it in:
>         // special-case read access to avoid needing to determine 
> effective
>         // access to file
>
> ... so people will better understand the trick.
>
> To my taste the line:
>         WindowsPath file = WindowsPath.toWindowsPath(obj);
> ... should be moved to the place, where it is actually needed.
>
> -Ulf
>
>>> On 23/08/2012 00:33, Ulf Zibis wrote:
>>>
>>>> At least the boolean one could be saved easily and (modes.length == 
>>>> 0) is superfluous:
>>>>
>>>>     public void checkAccess(Path obj, AccessMode... modes) throws 
>>>> IOException {
>>>>         AccessMode r = null;
>>>>         AccessMode w = null;
>>>>         AccessMode x = null;
>>>>         for (AccessMode mode: modes) {
>>>>             switch (mode) {
>>>>                 case READ : r = READ; break;
>>>>                 case WRITE : w = WRITE; break;
>>>>                 case EXECUTE : x = EXECUTE; break;
>>>>                 default: throw new AssertionError("Should not get 
>>>> here");
>>>>             }
>>>>         }
>>>>
>>>>         WindowsPath file = WindowsPath.toWindowsPath(obj);
>>>>
>>>>         // special-case read access to avoid needing to determine 
>>>> effective
>>>>         // access to file
>>>>         if (w == null && x == null) {
>>>>             tryReadAccess(file);
>>>>             return;
>>>>         }
>>
>

-- 
-Kurchi



More information about the nio-dev mailing list