This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push:
new fe246514 No need to convert a List to an array
fe246514 is described below
commit fe246514982f9072e27c233f7eadca2275fa3e5b
Author: Gary David Gregory (Code signing key) <[email protected]>
AuthorDate: Sat Nov 19 16:07:59 2022 -0500
No need to convert a List to an array
---
src/main/java/org/apache/bcel/util/ClassPath.java | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java
b/src/main/java/org/apache/bcel/util/ClassPath.java
index 4784353c..0567c9a9 100644
--- a/src/main/java/org/apache/bcel/util/ClassPath.java
+++ b/src/main/java/org/apache/bcel/util/ClassPath.java
@@ -527,7 +527,7 @@ public class ClassPath implements Closeable {
private final ClassPath parent;
- private final AbstractPathEntry[] paths;
+ private final List<AbstractPathEntry> paths;
/**
* Search for classes in CLASSPATH.
@@ -543,7 +543,7 @@ public class ClassPath implements Closeable {
public ClassPath(final ClassPath parent, final String classPath) {
this.parent = parent;
this.classPath = classPath;
- final List<AbstractPathEntry> list = new ArrayList<>();
+ this.paths = new ArrayList<>();
for (final StringTokenizer tokenizer = new StringTokenizer(classPath,
File.pathSeparator); tokenizer.hasMoreTokens();) {
final String path = tokenizer.nextToken();
if (!path.isEmpty()) {
@@ -551,13 +551,13 @@ public class ClassPath implements Closeable {
try {
if (file.exists()) {
if (file.isDirectory()) {
- list.add(new Dir(path));
+ paths.add(new Dir(path));
} else if (path.endsWith(".jmod")) {
- list.add(new Module(new ZipFile(file)));
+ paths.add(new Module(new ZipFile(file)));
} else if
(path.endsWith(ModularRuntimeImage.MODULES_PATH)) {
- list.add(new
JrtModules(ModularRuntimeImage.MODULES_PATH));
+ paths.add(new
JrtModules(ModularRuntimeImage.MODULES_PATH));
} else {
- list.add(new Jar(new ZipFile(file)));
+ paths.add(new Jar(new ZipFile(file)));
}
}
} catch (final IOException e) {
@@ -567,9 +567,6 @@ public class ClassPath implements Closeable {
}
}
}
- paths = new AbstractPathEntry[list.size()];
- list.toArray(paths);
-
}
/**
@@ -583,12 +580,9 @@ public class ClassPath implements Closeable {
@Override
public void close() throws IOException {
- if (paths != null) {
- for (final AbstractPathEntry path : paths) {
- path.close();
- }
+ for (final AbstractPathEntry path : paths) {
+ path.close();
}
-
}
@Override