You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/07/18 00:32:35 UTC

svn commit: r422905 - /directory/branches/shared/optimization/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java

Author: elecharny
Date: Mon Jul 17 15:32:35 2006
New Revision: 422905

URL: http://svn.apache.org/viewvc?rev=422905&view=rev
Log:
- Created a static final boolean IS_DEBUG which is initialized with the 
logger when the class is loaded : this will be evaluated only once, so
we will avoid a lot of isDebugEnabled() calls.

Modified:
    directory/branches/shared/optimization/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java

Modified: directory/branches/shared/optimization/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java?rev=422905&r1=422904&r2=422905&view=diff
==============================================================================
--- directory/branches/shared/optimization/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java (original)
+++ directory/branches/shared/optimization/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java Mon Jul 17 15:32:35 2006
@@ -49,7 +49,10 @@
 
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( Asn1Decoder.class );
-
+    
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** This flag is used to indicate that there are more bytes in the stream */
     private static final boolean MORE = true;
 
@@ -249,7 +252,10 @@
             current = current.getParent();
         }
 
-        log.debug( "TLV Tree : {}", sb.toString() );
+        if ( IS_DEBUG ) 
+        {
+            log.debug( "TLV Tree : {}", sb.toString() );
+        }
     }
 
 
@@ -301,7 +307,7 @@
     private void treatTagEndState( IAsn1Container container ) throws DecoderException, NamingException
     {
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             Tag tag = container.getCurrentTLV().getTag();
             log.debug( "Tag {} has been decoded", tag.toString() );
@@ -417,7 +423,7 @@
 
                 byte octet = stream.get();
 
-                if ( log.isDebugEnabled() )
+                if ( IS_DEBUG )
                 {
                     log.debug( "  current byte : {}", Asn1StringUtils.dumpByte( octet ) );
                 }
@@ -490,7 +496,7 @@
         // exceeded by the current TLV.
         TLV parentTLV = container.getParentTLV();
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Parent length : {}", getParentLength( parentTLV ) );
         }
@@ -502,7 +508,7 @@
             tlv.setExpectedLength( length.getLength() );
             container.setParentTLV( tlv );
 
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "Root TLV[{}]", new Integer( tlv.getLength().getLength() ) );
             }
@@ -608,7 +614,7 @@
 
         }
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Length {} has been decoded", length.toString() );
         }
@@ -742,7 +748,7 @@
      */
     private boolean treatTLVDoneState( ByteBuffer stream, IAsn1Container container ) throws DecoderException, NamingException
     {
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             dumpTLVTree( container );
         }
@@ -862,14 +868,17 @@
 
         boolean hasRemaining = stream.hasRemaining();
 
-        log.debug( ">>>==========================================" );
-        log.debug( "--> Decoding a PDU" );
-        log.debug( ">>>------------------------------------------" );
+        if ( IS_DEBUG )
+        {
+            log.debug( ">>>==========================================" );
+            log.debug( "--> Decoding a PDU" );
+            log.debug( ">>>------------------------------------------" );
+        }
 
         while ( hasRemaining )
         {
 
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "--- State = {} ---", stateToString( container.getState() ) );
 
@@ -956,7 +965,7 @@
             }
         }
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "<<<------------------------------------------" );