You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by da...@apache.org on 2012/09/01 15:04:53 UTC

svn commit: r1379761 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMXSupport.java

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;
     }
+
 }