Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8271603: Unnecessary Vector usage in java.desktop #4680

@@ -57,6 +57,7 @@
import java.io.File;
import java.net.URI;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
@@ -1300,23 +1301,23 @@ void addItem(final File directory) {

// create File instances of each directory leading up to the top
File f = directory.getAbsoluteFile();
final Vector<File> path = new Vector<File>(10);
final ArrayList<File> path = new ArrayList<File>(10);
while (f.getParent() != null) {
path.addElement(f);
path.add(f);
f = getFileChooser().getFileSystemView().createFileObject(f.getParent());
};

// Add root file (the desktop) to the model
final File[] roots = getFileChooser().getFileSystemView().getRoots();
for (final File element : roots) {
path.addElement(element);
path.add(element);
}
fPathCount = path.size();

// insert all the path fDirectories leading up to the
// selected directory in reverse order (current directory at top)
for (int i = 0; i < path.size(); i++) {
fDirectories.addElement(path.elementAt(i));
fDirectories.addElement(path.get(i));
}

setSelectedItem(fDirectories.elementAt(0));
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
@@ -212,7 +212,7 @@ public String getFileName() {
directoryList : fileList;
Object[] files = list.getSelectedValues();
int len = files.length;
Vector<String> result = new Vector<String>(len + 1);
ArrayList<String> result = new ArrayList<String>(len + 1);

// we return all selected file names
for (int i = 0; i < len; i++) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@@ -1050,9 +1050,9 @@ private void addItem(File directory) {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
ArrayList<File> path = new ArrayList<File>(10);
do {
path.addElement(f);
path.add(f);
} while ((f = f.getParentFile()) != null);

int pathCount = path.size();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@@ -26,8 +26,8 @@
package sun.awt;

import java.awt.peer.FontPeer;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Vector;
import sun.font.SunFontManager;
import sun.java2d.FontSupport;
import java.nio.CharBuffer;
@@ -143,7 +143,7 @@ public CharsetString[] makeMultiCharsetString(char[] str, int offset, int len,
if (len < 1) {
return new CharsetString[0];
}
Vector<CharsetString> mcs = null;
ArrayList<CharsetString> mcs = null;
char[] tmpStr = new char[len];
char tmpChar = defaultChar;
boolean encoded = false;
@@ -198,10 +198,10 @@ public CharsetString[] makeMultiCharsetString(char[] str, int offset, int len,
}
if (currentFont != fd){
if (mcs == null) {
mcs = new Vector<>(3);
mcs = new ArrayList<>(3);
}
mcs.addElement(new CharsetString(tmpStr, lastIndex,
i-lastIndex, currentFont));
mcs.add(new CharsetString(tmpStr, lastIndex,
i-lastIndex, currentFont));
currentFont = fd;
fd = defaultFont;
lastIndex = i;
@@ -214,7 +214,7 @@ public CharsetString[] makeMultiCharsetString(char[] str, int offset, int len,
result = new CharsetString[1];
result[0] = cs;
} else {
mcs.addElement(cs);
mcs.add(cs);
result = mcs.toArray(new CharsetString[mcs.size()]);
}
return result;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@@ -789,9 +789,9 @@ public void addItem(File directory) {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
ArrayList<File> path = new ArrayList<File>(10);
do {
path.addElement(f);
path.add(f);
} while ((f = f.getParentFile()) != null);

int pathCount = path.size();
@@ -47,6 +47,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import java.util.Vector;
@@ -1139,9 +1140,9 @@ private void addItem(File directory) {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
ArrayList<File> path = new ArrayList<File>(10);
do {
path.addElement(f);
path.add(f);
} while ((f = f.getParentFile()) != null);

int pathCount = path.size();
@@ -40,7 +40,6 @@
import java.awt.image.ColorModel;
import java.awt.peer.WindowPeer;
import java.util.ArrayList;
import java.util.Vector;

import sun.awt.windows.WWindowPeer;
import sun.java2d.SunGraphicsEnvironment;
@@ -214,30 +213,30 @@ public GraphicsConfiguration[] getConfigurations() {

int max = getMaxConfigs(screen);
int defaultPixID = getDefaultPixID(screen);
Vector<GraphicsConfiguration> v = new Vector<>( max );
ArrayList<GraphicsConfiguration> v = new ArrayList<>( max );
if (defaultPixID == 0) {
// Workaround for failing GDI calls
defaultConfig = Win32GraphicsConfig.getConfig(this,
defaultPixID);
v.addElement(defaultConfig);
v.add(defaultConfig);
}
else {
for (int i = 1; i <= max; i++) {
if (isPixFmtSupported(i, screen)) {
if (i == defaultPixID) {
defaultConfig = Win32GraphicsConfig.getConfig(
this, i);
v.addElement(defaultConfig);
v.add(defaultConfig);
}
else {
v.addElement(Win32GraphicsConfig.getConfig(
v.add(Win32GraphicsConfig.getConfig(
this, i));
}
}
}
}
configs = new GraphicsConfiguration[v.size()];
v.copyInto(configs);
v.toArray(configs);
}
return configs.clone();
}