[Schmitzm-commits] r2164 - trunk/schmitzm-core/src/main/java/de/schmitzm/regex

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sun Dec 9 00:11:25 CET 2012


Author: alfonx
Date: 2012-12-09 00:11:25 +0100 (Sun, 09 Dec 2012)
New Revision: 2164

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-12-08 23:02:14 UTC (rev 2163)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-12-08 23:11:25 UTC (rev 2164)
@@ -27,6 +27,20 @@
 
 	final static Logger log = Logger.getLogger(RegexCache.class);
 
+	final static ThreadLocal<BNDM> bndms = new ThreadLocal<BNDM>() {
+		@Override
+		protected BNDM initialValue() {
+			return new BNDM();
+		}
+	};
+
+	final static ThreadLocal<BNDMCI> bndmcis = new ThreadLocal<BNDMCI>() {
+		@Override
+		protected BNDMCI initialValue() {
+			return new BNDMCI();
+		}
+	};
+
 	/**
 	 * Regex-Auswertungen komplett cachen
 	 */
@@ -130,7 +144,7 @@
 
 		if (canSpeedup) {
 
-			StringSearch bndm = speedUpIgnorecase ? new BNDMCI() : new BNDM();
+			StringSearch bndm = speedUpIgnorecase ? bndmcis.get() : bndms.get();
 			int searchString = bndm.searchString(value, regex);
 
 			int idx = searchString;



More information about the Schmitzm-commits mailing list