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

Ulf Zibis Ulf.Zibis at CoSoCo.de
Fri Aug 24 04:00:55 PDT 2012


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;
>>>         }
>



More information about the nio-dev mailing list