Skip to content

Commit e59f46d

Browse files
committed
Add <p>, remove IPV6_LEN, return directly
1 parent 38076c2 commit e59f46d

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class Networks<T> implements Iterator<DatabaseRecord<T>> {
5151
this.reader = reader;
5252
this.includeAliasedNetworks = includeAliasedNetworks;
5353
this.buffer = reader.getBufferHolder().get();
54-
this.nodes = new Stack<NetworkNode>();
54+
this.nodes = new Stack<>();
5555
this.typeParameterClass = typeParameterClass;
5656
for (NetworkNode node : nodes) {
5757
this.nodes.push(node);
@@ -96,7 +96,7 @@ public DatabaseRecord<T> next() {
9696
prefixLength -= 96;
9797
}
9898

99-
return new DatabaseRecord<T>(data, InetAddress.getByAddress(ip), prefixLength);
99+
return new DatabaseRecord<T>(data, ipAddr, prefixLength);
100100
} catch (IOException e) {
101101
throw new NetworksIterationException(e);
102102
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.maxmind.db;
22

33
/**
4+
* <p>
45
* This class represents an error encountered while iterating over the networks.
56
* The most likely causes are corrupt data in the database, or a bug in the reader code.
6-
*
7+
* </p>
8+
* <p>
79
* This exception extends RuntimeException because it is thrown by the iterator
810
* methods in {@link Networks}.
11+
* </p>
912
*
1013
* @see Networks
1114
*/

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
public final class Reader implements Closeable {
1919
private static final int IPV4_LEN = 4;
20-
private static final int IPV6_LEN = 6;
2120
private static final int DATA_SECTION_SEPARATOR_SIZE = 16;
2221
private static final byte[] METADATA_START_MARKER = {(byte) 0xAB,
2322
(byte) 0xCD, (byte) 0xEF, 'M', 'a', 'x', 'M', 'i', 'n', 'd', '.',
@@ -323,17 +322,14 @@ public <T> Networks<T> networksWithin(
323322
int node = traverseResult[0];
324323
int prefix = traverseResult[1];
325324

326-
Networks<T> networks = new Networks<T>(this, includeAliasedNetworks,
325+
return new Networks<T>(this, includeAliasedNetworks,
327326
new Networks.NetworkNode[]{new Networks.NetworkNode(ipBytes, prefix, node)},
328327
typeParameterClass);
329-
330-
return networks;
331328
}
332329

333330
/**
334331
* Returns the node number and the prefix for the network.
335-
* @param ip The ip address to travese.
336-
* @param node The number of the node.
332+
* @param ip The ip address to traverse.
337333
* @param bitCount The prefix.
338334
* @return int[]
339335
*/

0 commit comments

Comments
 (0)