Skip to content

Commit

Permalink
fix for NPE and small performance enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Aug 10, 2016
1 parent 2910fe3 commit 103a834
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions source/net/yacy/kelondro/blob/BEncodedHeap.java
Expand Up @@ -201,10 +201,9 @@ private static Map<String, byte[]> b2m(final byte[] b) {
final Map<String, BDecoder.BObject> map = bobj.getMap();
final Map<String, byte[]> m = new HashMap<String, byte[]>();
for ( final Map.Entry<String, BDecoder.BObject> entry : map.entrySet() ) {
if ( entry.getValue().getType() != BDecoder.BType.string ) {
continue;
}
m.put(entry.getKey(), entry.getValue().getString());
BObject ev = entry.getValue();
if ( ev == null || ev.getType() != BDecoder.BType.string ) continue;
m.put(entry.getKey(), ev.getString());
}
return m;
}
Expand Down Expand Up @@ -688,11 +687,8 @@ public static void main(final String[] args) {
m.put("k", "222".getBytes());
map.insert("789".getBytes(), m);
// iterate over keys
Map.Entry<byte[], Map<String, byte[]>> entry;
final Iterator<Map.Entry<byte[], Map<String, byte[]>>> i = map.iterator();
while ( i.hasNext() ) {
entry = i.next();
System.out.println(ASCII.String(entry.getKey()) + ": " + entry.getValue());
for (Map.Entry<byte[], Map<String, byte[]>> entry : map) {
System.out.println(ASCII.String(entry.getKey()) + ": " + ASCII.String(entry.getValue().values().iterator().next()));
}
// clean up
map.close();
Expand Down

0 comments on commit 103a834

Please sign in to comment.