summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2018-02-14 07:14:25 +0100
committerluccioman <luccioman@users.noreply.github.com>2018-02-14 07:14:25 +0100
commite9527cd0e511abdf746e01bbe52d4826355a32b7 (patch)
tree28405b891d307c713edc5e659b8ef40310b816e7 /source
parentdbf4c1cd76c2709a2613500104dbf37ea8548c8e (diff)
Reuse the same Pattern instance when matching multiple key/values
Diffstat (limited to 'source')
-rw-r--r--source/net/yacy/server/serverObjects.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/source/net/yacy/server/serverObjects.java b/source/net/yacy/server/serverObjects.java
index ae556b6b8..a13e4dfb3 100644
--- a/source/net/yacy/server/serverObjects.java
+++ b/source/net/yacy/server/serverObjects.java
@@ -495,8 +495,9 @@ public class serverObjects implements Serializable, Cloneable {
// the keyMapper may contain regular expressions as defined in String.matches
// this method is particulary useful when parsing the result of checkbox forms
final List<String> v = new ArrayList<String>();
+ final Pattern keyPattern = Pattern.compile(keyMapper);
for (final Map.Entry<String, String> entry: entrySet()) {
- if (entry.getKey().matches(keyMapper)) {
+ if (keyPattern.matcher(entry.getKey()).matches()) {
v.add(entry.getValue());
}
}
@@ -512,10 +513,10 @@ public class serverObjects implements Serializable, Cloneable {
public Map<String, String> getMatchingEntries(final String keyMapper) throws PatternSyntaxException {
// the keyMapper may contain regular expressions as defined in String.matches
// this method is particulary useful when parsing the result of checkbox forms
- final Pattern p = Pattern.compile(keyMapper);
+ final Pattern keyPattern = Pattern.compile(keyMapper);
final Map<String, String> map = new HashMap<>();
for (final Map.Entry<String, String> entry: entrySet()) {
- if (entry.getKey().matches(keyMapper)) {
+ if (keyPattern.matcher(entry.getKey()).matches()) {
map.put(entry.getKey(), entry.getValue());
}
}