mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8263561: Re-examine uses of LinkedList
Reviewed-by: redestad
This commit is contained in:
parent
6a3f8343bc
commit
249d641889
9 changed files with 45 additions and 47 deletions
|
@ -30,7 +30,7 @@ import java.net.NetworkInterface;
|
|||
import java.nio.channels.MembershipKey;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -94,7 +94,7 @@ class MembershipRegistry {
|
|||
keys = groups.get(group);
|
||||
}
|
||||
if (keys == null) {
|
||||
keys = new LinkedList<>();
|
||||
keys = new ArrayList<>();
|
||||
groups.put(group, keys);
|
||||
}
|
||||
keys.add(key);
|
||||
|
|
|
@ -40,14 +40,14 @@ import java.util.*;
|
|||
|
||||
abstract class AbstractPoller implements Runnable {
|
||||
|
||||
// list of requests pending to the poller thread
|
||||
private final LinkedList<Request> requestList;
|
||||
// requests pending to the poller thread
|
||||
private final ArrayDeque<Request> requests;
|
||||
|
||||
// set to true when shutdown
|
||||
private boolean shutdown;
|
||||
|
||||
protected AbstractPoller() {
|
||||
this.requestList = new LinkedList<>();
|
||||
this.requests = new ArrayDeque<>();
|
||||
this.shutdown = false;
|
||||
}
|
||||
|
||||
|
@ -216,11 +216,11 @@ abstract class AbstractPoller implements Runnable {
|
|||
private Object invoke(RequestType type, Object... params) throws IOException {
|
||||
// submit request
|
||||
Request req = new Request(type, params);
|
||||
synchronized (requestList) {
|
||||
synchronized (requests) {
|
||||
if (shutdown) {
|
||||
throw new ClosedWatchServiceException();
|
||||
}
|
||||
requestList.add(req);
|
||||
requests.add(req);
|
||||
|
||||
// wakeup thread
|
||||
wakeup();
|
||||
|
@ -243,9 +243,9 @@ abstract class AbstractPoller implements Runnable {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
boolean processRequests() {
|
||||
synchronized (requestList) {
|
||||
synchronized (requests) {
|
||||
Request req;
|
||||
while ((req = requestList.poll()) != null) {
|
||||
while ((req = requests.poll()) != null) {
|
||||
// if in process of shutdown then reject request
|
||||
if (shutdown) {
|
||||
req.release(new ClosedWatchServiceException());
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package sun.util.locale.provider;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -98,7 +98,7 @@ public final class TimeZoneNameUtility {
|
|||
|
||||
// Performs per-ID retrieval.
|
||||
Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs();
|
||||
List<String[]> zones = new LinkedList<>();
|
||||
List<String[]> zones = new ArrayList<>();
|
||||
for (String key : zoneIDs) {
|
||||
String[] names = retrieveDisplayNamesImpl(key, locale);
|
||||
if (names != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue