mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8210347: Combine subsequent calls to Set.contains() and Set.add()
Reviewed-by: smarks, bpb
This commit is contained in:
parent
9118c4c28b
commit
475d422094
4 changed files with 6 additions and 10 deletions
|
@ -938,8 +938,7 @@ public final class ServiceLoader<S>
|
|||
List<ModuleLayer> parents = layer.parents();
|
||||
for (int i = parents.size() - 1; i >= 0; i--) {
|
||||
ModuleLayer parent = parents.get(i);
|
||||
if (!visited.contains(parent)) {
|
||||
visited.add(parent);
|
||||
if (visited.add(parent)) {
|
||||
stack.push(parent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 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
|
||||
|
@ -170,8 +170,7 @@ final class DistinctOps {
|
|||
|
||||
@Override
|
||||
public void accept(T t) {
|
||||
if (!seen.contains(t)) {
|
||||
seen.add(t);
|
||||
if (seen.add(t)) {
|
||||
downstream.accept(t);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue