Skip to content
Permalink
Browse files
8274497: Unnecessary Vector usage in AquaFileSystemModel
Reviewed-by: serb, pbansal
  • Loading branch information
turbanoff authored and mrserb committed Oct 7, 2021
1 parent c833b4d commit 4e960fe53f0948c0b0decfeb13f6dd8f74bf3d6f
Showing 1 changed file with 8 additions and 8 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, 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
@@ -47,8 +47,8 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
private Vector<File> files = null;

JFileChooser filechooser = null;
Vector<SortableFile> fileCache = null;
Object fileCacheLock;
ArrayList<SortableFile> fileCache = null;
final Object fileCacheLock;

Vector<File> directories = null;
int fetchID = 0;
@@ -136,7 +136,7 @@ public Vector<File> getFiles() {

synchronized(fileCacheLock) {
for (int i = 0; i < fileCache.size(); i++) {
final SortableFile sf = fileCache.elementAt(i);
final SortableFile sf = fileCache.get(i);
final File f = sf.fFile;
if (filechooser.isTraversable(f)) {
directories.addElement(f);
@@ -180,7 +180,7 @@ public void validateFileCache() {
// PENDING(jeff) pick the size more sensibly
invalidateFileCache();
synchronized(fileCacheLock) {
fileCache = new Vector<SortableFile>(50);
fileCache = new ArrayList<>(50);
}

filesLoader = new FilesLoader(currentDirectory, fetchID);
@@ -244,7 +244,7 @@ public Object getValueAt(int row, final int col) {
synchronized(fileCacheLock) {
if (fileCache != null) {
if (!isAscending) row = fileCache.size() - row - 1;
return fileCache.elementAt(row).getValueAt(col);
return fileCache.get(row).getValueAt(col);
}
return null;
}
@@ -383,7 +383,7 @@ public int hashCode() {
}

class FilesLoader implements Runnable {
Vector<Runnable> queuedTasks = new Vector<>();
ArrayList<Runnable> queuedTasks = new ArrayList<>();
File currentDirectory = null;
int fid;
Thread loadThread;
@@ -473,7 +473,7 @@ public void run() {
synchronized(fileCacheLock) {
if (fileCache != null) {
for (int i = 0; i < contentFiles.size(); i++) {
fileCache.addElement(contentFiles.elementAt(i));
fileCache.add(contentFiles.elementAt(i));
fireTableRowsInserted(i, i);
}
}

1 comment on commit 4e960fe

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 4e960fe Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.