[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: About Strings and reference of strings

Jano Svitok

1/9/2007 11:49:00 AM

On 1/9/07, Jonas Pfenniger <zimbatm@oree.ch> wrote:
> Hello,
>
> while writing a simple syslog message parser, something struck me and now I
> would like to know :
> What happens internally if you make a new string from a range of another
> string ?
>
> You have a new String object. But what happens to the internal data ? Is the
> char range copied to the new string object or is a reference created to the
> range in the old string ?
>
> If the data is copied over, I propose to introduce a new RefString Class as
> a C extension that would typically be used by parsers and tokenizers.
>
> Cheers,
> zimbatm

You can see for yourself in string.c ;-)
Arrays are shared, so I *suppose* Strings are as well.