Author: elecharny
Date: Sun Apr 3 10:26:40 2005
New Revision: 159935
URL: http://svn.apache.org/viewcvs?view=rev&rev=159935
Log:
Used poolable MutableString instead of String to allocate strings in POJOs.
It's faster (20%), and all the decoder is now working with pools.
1 000 000 BindRequest decoded in 4.4 seconds (IBM JVM 1.4.2)
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageGrammar.java
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageGrammar.java
URL:
http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageGrammar.java?view=diff&r1=159934&r2=159935
==============================================================================
---
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageGrammar.java
(original)
+++
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageGrammar.java
Sun Apr 3 10:26:40 2005
@@ -25,12 +25,12 @@
import org.apache.asn1.ber.tlv.TLV;
import org.apache.asn1.ber.tlv.Value;
import org.apache.asn1.ldap.codec.primitives.IntegerDecoder;
-import org.apache.asn1.ldap.codec.primitives.LdapDNDecoder;
import org.apache.asn1.ldap.pojo.AbstractPOJO;
import org.apache.asn1.ldap.pojo.BindRequestPOJO;
import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
import org.apache.asn1.ldap.pojo.LdapPOJO;
import org.apache.asn1.ldap.pojo.SimpleAuthenticationPOJO;
+import org.apache.asn1.util.MutableString;
import org.apache.asn1.util.pools.PoolEnum;
import org.apache.asn1.util.pools.PoolException;
@@ -308,13 +308,24 @@
// Get the Value and store it in the BindRequest
TLV tlv =
ldapMessageContainer.getCurrentTLV();
- // TODO : allocate the string from a pool.
- String value = LdapDNDecoder.parse(tlv.getValue());
- //String value = new String(tlv.getValue().getData());
+ MutableString name = null;
+
+ try
+ {
+ name = ( MutableString )
ldapMessageContainer.getPoolManager().allocateString(tlv.getValue().getData().length);
+ }
+ catch (PoolException pe)
+ {
+ throw new DecoderException(
+ "Cannot allocate a MutableString
for Name : " + pe.getMessage() );
+ }
+
+ name.setData(tlv.getValue().getData());
+
BindRequestPOJO bindRequestMessage =
(BindRequestPOJO)ldapMessageContainer.getLdapMessage().getProtocolOp();
- bindRequestMessage.setName(value);
+ bindRequestMessage.setName(name);
return;
}
} );
@@ -352,8 +363,19 @@
// Get the Value and store it in the BindRequest
TLV tlv =
ldapMessageContainer.getCurrentTLV();
- // TODO : allocate the string from a pool.
- String simple = new String(tlv.getValue().getData());
+ MutableString simple = null;
+
+ try
+ {
+ simple = ( MutableString )
ldapMessageContainer.getPoolManager().allocateString(tlv.getValue().getData().length);
+ }
+ catch (PoolException pe)
+ {
+ throw new DecoderException(
+ "Cannot allocate a MutableString
for simple : " + pe.getMessage() );
+ }
+
+ simple.setData(tlv.getValue().getData());
BindRequestPOJO bindRequestMessage =
(BindRequestPOJO)ldapMessageContainer.getLdapMessage().getProtocolOp();