8210347: Combine subsequent calls to Set.contains() and Set.add()

Reviewed-by: smarks, bpb
This commit is contained in:
Ivan Gerasimov 2018-09-11 14:51:45 -07:00
parent 9118c4c28b
commit 475d422094
4 changed files with 6 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -790,8 +790,7 @@ public final class ModuleLayer {
// push in reverse order
for (int i = layer.parents.size() - 1; i >= 0; i--) {
ModuleLayer parent = layer.parents.get(i);
if (!visited.contains(parent)) {
visited.add(parent);
if (visited.add(parent)) {
stack.push(parent);
}
}