nobu.nokada / softhome.net writes:

> ===================================================================
> RCS file: /cvs/ruby/src/ruby/string.c,v

I'll try to understand this new string code, but I wonder if you could
explain a few things.  My basic problem is that STR_ASSOC and
ELTS_SHARED are not clear to me.

ELTS_SHARED -- means string shares same data buffer with some other
string -- must make copy to modify.

STR_ASSOC -- I could not figure it out.


> +    if (len > sizeof(struct RString)/2 &&

This just makes sure the new behavior does not happen for very small
strings...

> +	beg + len == RSTRING(str)->len &&

And that it only happens when the new string is a tail of the old.

> +	!FL_TEST(str, STR_ASSOC)) {

And when the original string is not ??? (what is STR_ASSOC?)

> +	if (!FL_TEST(str, ELTS_SHARED)) str = rb_str_new4(str);

If the old string is ELTS_SHARED, create a new ELTS_SHARED string copy
that is frozen.  Maybe I miss something here.

> +	str2 = rb_str_new3(str);

str2 shares same data as str...

> +	RSTRING(str2)->ptr += beg;
> +	RSTRING(str2)->len = len;

But points to some suffix of it...