8199124: (fs) Reduce allocation for file system methods that are invoked with no open options

Reviewed-by: alanb
This commit is contained in:
Michael Skells 2018-06-21 11:10:55 -07:00 committed by Brian Burkhalter
parent 91d9f3fbe0
commit df509b1b16
4 changed files with 36 additions and 16 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -335,8 +335,13 @@ public abstract class FileChannel
public static FileChannel open(Path path, OpenOption... options)
throws IOException
{
Set<OpenOption> set = new HashSet<>(options.length);
Collections.addAll(set, options);
Set<OpenOption> set;
if (options.length == 0) {
set = Collections.emptySet();
} else {
set = new HashSet<>();
Collections.addAll(set, options);
}
return open(path, set, NO_ATTRIBUTES);
}