directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r996696 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers: GeneralizedTimeSyntaxChecker.java UtcTimeSyntaxChecker.java
Date Mon, 13 Sep 2010 21:39:06 GMT
Author: seelmann
Date: Mon Sep 13 21:39:06 2010
New Revision: 996696

URL: http://svn.apache.org/viewvc?rev=996696&view=rev
Log:
Optimization, patch from Richard M Feezel

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/UtcTimeSyntaxChecker.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java?rev=996696&r1=996695&r2=996696&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/GeneralizedTimeSyntaxChecker.java
Mon Sep 13 21:39:06 2010
@@ -88,8 +88,8 @@ public class GeneralizedTimeSyntaxChecke
                 "([.,]\\d+)?" +                             // fraction       
                 "(Z|[+-]([01]\\d|2[0-3])([0-5]\\d)?)$";     // time-zone
     
-    // The regexp pattern matcher
-    private Pattern datePattern = Pattern.compile( GENERALIZED_TIME_PATTERN ); 
+    // The regexp pattern is immutable, only one instance needed.
+    private static final Pattern DATE_PATTERN = Pattern.compile( GENERALIZED_TIME_PATTERN
); 
 
     /**
      * Creates a new instance of GeneralizedTimeSyntaxChecker.
@@ -134,7 +134,7 @@ public class GeneralizedTimeSyntaxChecke
         }
         
         // Start the date parsing
-        boolean result = datePattern.matcher( strValue ).find();
+        boolean result = DATE_PATTERN.matcher( strValue ).find();
         
         if ( result )
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/UtcTimeSyntaxChecker.java?rev=996696&r1=996695&r2=996696&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/UtcTimeSyntaxChecker.java
Mon Sep 13 21:39:06 2010
@@ -81,8 +81,8 @@ public class UtcTimeSyntaxChecker extend
                     "(Z|([+-]([01]\\d|2[0-3])[0-5]\\d))?" + // optionnal time-zone
                 ")$";
     
-    // The regexp pattern matcher
-    private Pattern datePattern = Pattern.compile( UTC_TIME_PATTERN ); 
+    // The regexp pattern, java.util.regex.Pattern is immutable so only one instance is needed.
+    private static final Pattern DATE_PATTERN = Pattern.compile( UTC_TIME_PATTERN ); 
 
     /**
      * 
@@ -129,7 +129,7 @@ public class UtcTimeSyntaxChecker extend
         }
         
         // Start the date parsing
-        boolean result = datePattern.matcher( strValue ).find();
+        boolean result = DATE_PATTERN.matcher( strValue ).find();
         
         if ( result )
         {



Mime
View raw message