Small complementary memory footprint improvement for synonyms.

Memory footprint measured with VisualVM and all synonyms enabled :
 - before : 195 015 914 bytes
 - after : 192 548 826 bytes
pull/93/head
luccioman 8 years ago
parent 568e3dde6a
commit 7f846ef674

@ -63,8 +63,8 @@ public class SynonymLibrary {
if (line.charAt(line.length() - 1) == '}') line = line.substring(0, line.length() - 1);
if (line.charAt(0) == '{') line = line.substring(1);
String[] words = CommonPattern.COMMA.split(line);
Set<String> synonyms = new HashSet<String>();
Set<String> keys = new HashSet<String>();
Set<String> synonyms = new HashSet<String>(words.length);
Set<String> keys = new HashSet<String>(words.length);
for (String word: words) {
word = word.trim();
if (word.length() < 2) continue;
@ -102,7 +102,7 @@ public class SynonymLibrary {
/**
* for a given word, return a list of synonym words
* @param word
* @return a list of synonyms bot without the requested word
* @return a list of synonyms but without the requested word
*/
public static Set<String> getSynonyms(String word) {
if (word == null) return null;

Loading…
Cancel
Save