Skip to content

Commit 9b82f3f

Browse files
oschwaldclaude
andcommitted
Replace legacy collections with modern alternatives
Replace Stack with ArrayDeque in Networks.java for better performance by removing unnecessary synchronization overhead. Replace Vector with ArrayList in test code for consistency with modern Java practices. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 2654c85 commit 9b82f3f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/com/maxmind/db/Networks.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import java.io.IOException;
44
import java.net.Inet4Address;
55
import java.net.InetAddress;
6+
import java.util.ArrayDeque;
67
import java.util.Arrays;
8+
import java.util.Deque;
79
import java.util.Iterator;
8-
import java.util.Stack;
910

1011
/**
1112
* Instances of this class provide an iterator over the networks in a database.
@@ -15,7 +16,7 @@
1516
*/
1617
public final class Networks<T> implements Iterator<DatabaseRecord<T>> {
1718
private final Reader reader;
18-
private final Stack<NetworkNode> nodes;
19+
private final Deque<NetworkNode> nodes;
1920
private NetworkNode lastNode;
2021
private final boolean includeAliasedNetworks;
2122
private final Buffer buffer; /* Stores the buffer for Next() calls */
@@ -39,7 +40,7 @@ public final class Networks<T> implements Iterator<DatabaseRecord<T>> {
3940
this.reader = reader;
4041
this.includeAliasedNetworks = includeAliasedNetworks;
4142
this.buffer = reader.getBufferHolder().get();
42-
this.nodes = new Stack<>();
43+
this.nodes = new ArrayDeque<>();
4344
this.typeParameterClass = typeParameterClass;
4445
for (NetworkNode node : nodes) {
4546
this.nodes.push(node);

src/test/java/com/maxmind/db/ReaderTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.HashMap;
2828
import java.util.List;
2929
import java.util.Map;
30-
import java.util.Vector;
3130
import java.util.concurrent.ConcurrentHashMap;
3231
import java.util.stream.IntStream;
3332

@@ -1397,12 +1396,12 @@ public void testDecodeVector(int chunkSize) throws IOException {
13971396
}
13981397

13991398
static class TestModelVector {
1400-
Vector<Long> arrayField;
1399+
ArrayList<Long> arrayField;
14011400

14021401
@MaxMindDbConstructor
14031402
public TestModelVector(
14041403
@MaxMindDbParameter(name = "array")
1405-
Vector<Long> arrayField
1404+
ArrayList<Long> arrayField
14061405
) {
14071406
this.arrayField = arrayField;
14081407
}

0 commit comments

Comments
 (0)