mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8287285: Avoid redundant HashMap.containsKey call in java.util.zip.ZipFile.Source.get
Reviewed-by: jpai, alanb
This commit is contained in:
parent
7cb368b34d
commit
295be6f10f
1 changed files with 5 additions and 6 deletions
|
@ -1292,13 +1292,12 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
src = new Source(key, toDelete, zc);
|
||||
|
||||
synchronized (files) {
|
||||
if (files.containsKey(key)) { // someone else put in first
|
||||
Source prev = files.putIfAbsent(key, src);
|
||||
if (prev != null) { // someone else put in first
|
||||
src.close(); // close the newly created one
|
||||
src = files.get(key);
|
||||
src.refs++;
|
||||
return src;
|
||||
prev.refs++;
|
||||
return prev;
|
||||
}
|
||||
files.put(key, src);
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue