Small memory footprint reduction for GeonamesLocation.

Reusing the same geonameid Integer instance between `id2loc` and
`name2ids` maps reduces (a little) memory footprint.
Measured OverarchigLocation class retained memory with VisualVM on
openJDK 8 :
 - initial : 183 439 490 bytes
 - after refactoring : 164 666 830 bytes
pull/97/head
luccioman 8 years ago
parent 7f846ef674
commit 6bc2bf1aa4

@ -133,7 +133,7 @@ public class GeonamesLocation implements Locations {
fields = CommonPattern.TAB.split(line); fields = CommonPattern.TAB.split(line);
final long population = Long.parseLong(fields[14]); final long population = Long.parseLong(fields[14]);
if (minPopulation > 0 && population < minPopulation) continue; if (minPopulation > 0 && population < minPopulation) continue;
final int geonameid = Integer.parseInt(fields[0]); final Integer geonameid = Integer.valueOf(fields[0]);
locnames = new HashSet<StringBuilder>(); locnames = new HashSet<StringBuilder>();
locnames.add(new StringBuilder(fields[1])); locnames.add(new StringBuilder(fields[1]));
locnames.add(new StringBuilder(fields[2])); locnames.add(new StringBuilder(fields[2]));

Loading…
Cancel
Save