[Schmitzm-commits] r2015 - trunk/schmitzm-core/src/main/java/de/schmitzm/regex
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sat May 26 23:06:05 CEST 2012
Author: alfonx
Date: 2012-05-26 23:06:05 +0200 (Sat, 26 May 2012)
New Revision: 2015
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
Log:
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java 2012-05-26 21:03:23 UTC (rev 2014)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java 2012-05-26 21:06:05 UTC (rev 2015)
@@ -70,8 +70,8 @@
return false;
final String value = object instanceof String ? (String) object : object.toString();
-// Matcher m = getMatcher(regex, value);
-// return m.find();
+ // Matcher m = getMatcher(regex, value);
+ // return m.find();
return result(regex, value) != null;
}
@@ -95,7 +95,7 @@
final static Map<String, ThreadLocal<Matcher>> matchersCachedThreadLocalPerRegex = new ConcurrentHashMap<String, ThreadLocal<Matcher>>(
10000);
-
+
public static boolean matcherCache = false;
/**
@@ -106,12 +106,11 @@
* angeforderd, wird zuerst {@link Matcher#reset(CharSequence)} ausgeführt.
*/
public Matcher getMatcher(final String regex, final String text) {
-
+
if (!matcherCache) {
return getPattern(regex).matcher(text);
}
-
-
+
ThreadLocal<Matcher> threadLocal = matchersCachedThreadLocalPerRegex.get(regex);
synchronized (regex) {
@@ -189,7 +188,8 @@
synchronized (matcherResults) {
m = matcherResults.get(pattern);
if (m == null) {
- matcherResults.put(pattern, m = new ConcurrentHashMap<String, MyMatchResult>(CACHE_VALUES_TO_RESULT_SIZE));
+ matcherResults.put(pattern, m = new ConcurrentHashMap<String, MyMatchResult>(
+ CACHE_VALUES_TO_RESULT_SIZE));
}
}
// LimitedConcurrentHashMap<String, MyMatchResult> m;
@@ -205,7 +205,8 @@
synchronized (m) {
matcher = m.get(value);
if (matcher == null) {
- final Matcher xm = pattern.matcher(value);
+ // final Matcher xm = pattern.matcher(value);
+ final Matcher xm = getMatcher(regex, value);
if (xm.find())
matcher = new MyMatchResult(xm.toMatchResult());
else
More information about the Schmitzm-commits
mailing list