Inefficient iterators in FNDS methods
getLocalClientsBlindData() and lookupClientBySigningPublicKey() :
+ for (String subdb : _subDBs.keySet()) {
+ rv.addAll(_subDBs.get(subdb).getBlindData());
It's very inefficient to iterate thru keys simply to do a Map.get() on each one and operate on the value. This is a Java anti-pattern caught by findbugs.
Do instead:
for (FNDF subdb : _subDBs.values())
Similarly, with getLeasesKnownToClients(), getRoutersKnownToClients(), and getClients() :
+ for (String key : _subDBs.keySet()) {
+ if (key != null && !key.isEmpty()) {
+ if (key.startsWith("client"))
+ rv.addAll(this.getSubNetDB(key).getRouters());
If you need to access both the key and value, use the _subDBs.entrySet() iterator instead.
However, if you remove the maindb from the subDBs map as I recommend in #404 (closed) comment 1, then you don't need the key and you can simply use the values() iterator as above.