Have there been any thoughts of implementing RubyString as byte[]
instead of String?  Or maybe java.nio.ByteBuffer?

This fits better with the Ruby paradigm of what a String *is*, saves
memory (since RubyStrings are binary data, there is one wasted byte for
every byte of real data in a Java string), would save a conversion on IO
calls, etc.  Also, this would make that creepy feeling in the back of my
head go away when I know Java Strings are containing somewhat binary
data :-)

Its possible this ends up being actually *less* of a pain to do stuff
with in the long run from the issues one would avoid.

Evan

Charles O Nutter wrote:
> Blast, forgot the patch.
> 
> On 6/4/06, *Charles O Nutter* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     ObjectSpace is slow.
> 
>     I'm optimizing RubyString and seeing again and again how slow OS
>     makes object creation. I've attached a patch that doesn't break
>     anything and optimizes a few aspects of RubyString. Without OS
>     enabled, this patch gives 15-20% improvement in the given
>     microbenchmark. It's not quite as substantial as the gains from
>     disabling OS, but it's faster and faster.
> 
>     Changes:
>     - Don't call getClass("String") for every string instantiation;
>     added IRuby.getString() to save the class on creation. This could be
>     done for all builtins. Resulted in 5-10% faster excluding OS.
>     - Don't create StringBuffer right away; use CharSequence everywhere,
>     create StringBuffer only when needed and use SB from then on.
>     Resulted in another 5-10% faster excluding OS.
> 
>     1_000_000.times { <14 literal strings> }
> 
>     No optimization, OS enabled: 75s
>     String optimization, OS enabled: 72s
>     No optimization, OS disabled: 17s
>     String optimization, OS disabled: 14s
> 
>     -- 
>     Charles Oliver Nutter @ headius.blogspot.com
>     <http://headius.blogspot.com>
>     JRuby Developer @ jruby.sourceforge.net <http://jruby.sourceforge.net>
>     Application Architect @ www.ventera.com <http://www.ventera.com> 
> 
> 
> 
> 
> -- 
> Charles Oliver Nutter @ headius.blogspot.com <http://headius.blogspot.com>
> JRuby Developer @ jruby.sourceforge.net <http://jruby.sourceforge.net>
> Application Architect @ www.ventera.com <http://www.ventera.com>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Jruby-devel mailing list
> Jruby-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jruby-devel


_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to