GeoIP: Reduce object churn, add test to command line tools

This commit is contained in:
zzz
2018-11-25 15:16:18 +00:00
parent 43e0d4f910
commit dc8a822b0e
2 changed files with 5 additions and 3 deletions

View File

@ -7,7 +7,6 @@ import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -255,6 +254,7 @@ final class Decoder {
}
}
/** @return modifiable, don't modify it */
private List<Object> decodeArray(int size) throws IOException {
List<Object> array = new ArrayList<Object>(size);
@ -263,9 +263,10 @@ final class Decoder {
array.add(r);
}
return Collections.unmodifiableList(array);
return array;
}
/** @return modifiable, don't modify it */
private Map<String, Object> decodeMap(int size) throws IOException {
int capacity = (int) (size / 0.75F + 1.0F);
Map<String, Object> map = new HashMap<String, Object>(capacity);
@ -276,7 +277,7 @@ final class Decoder {
map.put(key, value);
}
return Collections.unmodifiableMap(map);
return map;
}
private byte[] getByteArray(int length) {

View File

@ -14,6 +14,7 @@ import java.util.List;
public class CommandLine extends net.i2p.util.CommandLine {
protected static final List<String> RCLASSES = Arrays.asList(new String[] {
"com.maxmind.geoip2.DatabaseReader",
"net.i2p.data.router.RouterInfo",
"net.i2p.data.router.RouterKeyGenerator",
"net.i2p.router.MultiRouter",