From: Christian Neukirchen Date: 2006-07-29T22:53:30+09:00 Subject: Re: String#chop slow? REALLY slow? Jake McArthur writes: > Let's see how String#chop is implemented... > > > static VALUE > rb_str_chop(str) > VALUE str; > { > str = rb_str_dup(str); > rb_str_chop_bang(str); > return str; > } > > > So it's in C... interesting.... And that's the reason why it's slower... it always dups the string, while string[a..b] creates a shared substring (copy-on-write). > - Jake McArthur > -- Christian Neukirchen http://chneukirchen.org