directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1573127 - /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosEncoder.java
Date Sat, 01 Mar 2014 06:49:34 GMT
Author: kayyagari
Date: Sat Mar  1 06:49:33 2014
New Revision: 1573127

URL: http://svn.apache.org/r1573127
Log:
avoid copying the buffer

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosEncoder.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosEncoder.java?rev=1573127&r1=1573126&r2=1573127&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosEncoder.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosEncoder.java
Sat Mar  1 06:49:33 2014
@@ -34,30 +34,31 @@ public class KerberosEncoder
 {
     public static ByteBuffer encode( AbstractAsn1Object asn1Obj, boolean isTcp ) throws IOException
     {
-        ByteBuffer response = null;
         ByteBuffer kerberosMessage = null;
 
         int responseLength = asn1Obj.computeLength();
-        kerberosMessage = ByteBuffer.allocate( responseLength );
+        
+        int bufferLen = responseLength;
+        
+        if ( isTcp )
+        {
+            bufferLen += 4;
+        }
+        
+        kerberosMessage = ByteBuffer.allocate( bufferLen );
 
+        if( isTcp )
+        {
+            kerberosMessage.putInt( responseLength );
+        }
+        
         try
         {
             asn1Obj.encode( kerberosMessage );
 
-            if ( isTcp )
-            {
-                response = ByteBuffer.allocate( responseLength + 4 );
-                response.putInt( responseLength );
-                response.put( kerberosMessage.array() );
-            }
-            else
-            {
-                response = kerberosMessage;
-            }
-
-            response.flip();
+            kerberosMessage.flip();
 
-            return response;
+            return kerberosMessage;
         }
         catch ( EncoderException e )
         {



Mime
View raw message