mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
memory optimizations
This commit is contained in:
@@ -10,7 +10,6 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -133,11 +132,7 @@ public class FeedUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String replaceHtmlEntitiesWithNumericEntities(String source) {
|
public static String replaceHtmlEntitiesWithNumericEntities(String source) {
|
||||||
String result = source;
|
return StringUtils.replaceEach(source, HtmlEntities.HTML_ENTITIES, HtmlEntities.NUMERIC_ENTITIES);
|
||||||
for (Map.Entry<String, String> entry : HtmlEntities.NUMERIC_MAPPING.entrySet()) {
|
|
||||||
result = StringUtils.replace(result, entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.commafeed.backend.feed;
|
package com.commafeed.backend.feed;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class HtmlEntities {
|
public class HtmlEntities {
|
||||||
public static final Map<String, String> NUMERIC_MAPPING = Collections.unmodifiableMap(loadMap());
|
public static final String[] HTML_ENTITIES;
|
||||||
|
public static final String[] NUMERIC_ENTITIES;
|
||||||
|
|
||||||
private static synchronized Map<String, String> loadMap() {
|
static {
|
||||||
Map<String, String> map = new LinkedHashMap<>();
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
map.put("Á", "Á");
|
map.put("Á", "Á");
|
||||||
map.put("á", "á");
|
map.put("á", "á");
|
||||||
@@ -260,6 +260,7 @@ public class HtmlEntities {
|
|||||||
map.put("‍", "‍");
|
map.put("‍", "‍");
|
||||||
map.put("‌", "‌");
|
map.put("‌", "‌");
|
||||||
|
|
||||||
return map;
|
HTML_ENTITIES = map.keySet().toArray(new String[map.size()]);
|
||||||
|
NUMERIC_ENTITIES = map.values().toArray(new String[map.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user