tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1140204 - /tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
Date Mon, 27 Jun 2011 15:49:19 GMT
2011/6/27  <markt@apache.org>:
> Author: markt
> Date: Mon Jun 27 15:19:22 2011
> New Revision: 1140204
>
> URL: http://svn.apache.org/viewvc?rev=1140204&view=rev
> Log:
> Need to include aliases in charset cache
>
> Modified:
>    tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
>

15:19:22 2011
> @@ -55,8 +55,11 @@ public class B2CConverter {
>     static {
>         for (Entry<String,Charset> entry :
>                 Charset.availableCharsets().entrySet()) {
> -            encodingToCharsetCache.put(entry.getKey().toLowerCase(),
> -                    entry.getValue());
> +            Charset charset = entry.getValue();
> +            encodingToCharsetCache.put(entry.getKey().toLowerCase(), charset);

Getting the name can be a bit simplified:

  charset.name().toLowerCase(Locale.US)

thus no need to access the key and loop can be simplified a bit.

> +            for (String alias : charset.aliases()) {
> +                encodingToCharsetCache.put(alias, charset);

Should be:
 s/alias/alias.toLowerCase(Locale.US)/

> +            }
>         }
>     }

I was wondering how slow is Charset.availableCharsets().
In my test it is about 100ms.  Nothing to worry about.

Best regards,
Konstantin Kolinko

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


Mime
View raw message