2014-10-13 23:27 GMT+04:00  <ma...@apache.org>:
> Author: markt
> Date: Mon Oct 13 19:27:37 2014
> New Revision: 1631520
>
> URL: http://svn.apache.org/r1631520
> Log:
> Cache the Encoder instances used to convert Strings to byte arrays in the 
> Connectors (e.g. when writing HTTP headers) to improve throughput.

In this implementation I think the cache only plays when the same
MessageBytes instance is re-used in subsequent requests.

I think an alternative implementation using a thread-local cache will
allow to reuse encoders between different MessageByte instances in the
same request and will require less memory.


Best regards,
Konstantin Kolinko

>
> Modified:
>     tomcat/trunk/java/org/apache/tomcat/util/buf/LocalStrings.properties
>     tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java
>     tomcat/trunk/webapps/docs/changelog.xml
>

> @@ -36,6 +44,9 @@ import java.util.Locale;
>  public final class MessageBytes implements Cloneable, Serializable {
>      private static final long serialVersionUID = 1L;
>
> +    private static final StringManager sm = StringManager.getManager(
> +            Constants.Package);
> +
>      // primary type ( whatever is set as original value )
>      private int type = T_NULL;
>
> @@ -64,6 +75,8 @@ public final class MessageBytes implemen
>      // strValue!=null is the same
>      private boolean hasStrValue=false;
>
> +    private Map<Charset,CharsetEncoder> encoders = new HashMap<>();
> +

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to