[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: Optimisations: A couple of low hanging fruits going for
trustin
do-not-reply at jboss.com
Wed May 14 12:44:04 EDT 2008
"timfox" wrote : "trustin" wrote :
| |
| | for (int i = 0; i < str.length(); i ++) {
| | buf.putChar(str.charAt(i));
| | }
|
| Well... UTF-8 is just putting a sequence of bytes generated from bitwise operations on the chars? So should be fast right?
|
| Maybe the overhead is due to the creation of the encoder class etc, I don't really know I haven't profiled it yet...
|
| Maybe we should just write our own encoding that writes directly onto a SimpleString...
Yes, the creation of a CharsetEncoder takes a lot of time and therefore cached somewhere. String.getBytes() uses ThreadLocal for this purpose, but if you already have some context object that stores the decoding/encoding state, then you can just add a field there.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4150823#4150823
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150823
More information about the jboss-dev-forums
mailing list