activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1379761 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java
Date Sat, 01 Sep 2012 13:04:53 GMT
Author: davsclaus
Date: Sat Sep  1 13:04:53 2012
New Revision: 1379761

URL: http://svn.apache.org/viewvc?rev=1379761&view=rev
Log:
AMQ-4010: Use pre compiled pattern when doing string replaceAll as its faster.

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java?rev=1379761&r1=1379760&r2=1379761&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java Sat
Sep  1 13:04:53 2012
@@ -16,17 +16,24 @@
  */
 package org.apache.activemq.util;
 
+import java.util.regex.Pattern;
+
 public final class JMXSupport {
 
+    private static final Pattern PART_1 = Pattern.compile("[\\:\\,\\'\\\"]");
+    private static final Pattern PART_2 = Pattern.compile("\\?");
+    private static final Pattern PART_3 = Pattern.compile("=");
+    private static final Pattern PART_4 = Pattern.compile("\\*");
+
     private JMXSupport() {
     }
 
     public static String encodeObjectNamePart(String part) {
-        // return ObjectName.quote(part);
-        String answer = part.replaceAll("[\\:\\,\\'\\\"]", "_");
-        answer = answer.replaceAll("\\?", "&qe;");
-        answer = answer.replaceAll("=", "&");
-        answer = answer.replaceAll("\\*", "*");
+        String answer = PART_1.matcher(part).replaceAll("_");
+        answer = PART_2.matcher(answer).replaceAll("&qe;");
+        answer = PART_3.matcher(answer).replaceAll("&");
+        answer = PART_4.matcher(answer).replaceAll("*");
         return answer;
     }
+
 }



Mime
View raw message