mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8199124: (fs) Reduce allocation for file system methods that are invoked with no open options
Reviewed-by: alanb
This commit is contained in:
parent
91d9f3fbe0
commit
df509b1b16
4 changed files with 36 additions and 16 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue