Re: Interesting Experiment With String/Sequence Slicing

new topic     » goto parent     » topic index » view thread      » older message » newer message

slie writes:
<several examples of slicing>

Without going through your examples in detail,
I'll just give you a few hints:

1. Whenever you see:

         x = y
    
     nothing happens except for a pointer being copied.
     and maybe a reference count being incremented.
     If y is a sequence, x and y will now point at a single
     copy of the same sequence.

2. When you see:

     y = x[a..b]

     Then the data from a to b is copied and a new sequence is
     created. (Back in v1.4 and earlier I used to just have y point at the data
     in x that it needed, but I later changed this).

3. When you see:

     x = x[a..b]

    and there are no other references to the sequence,
    then I simply adjust the pointers to the beginning and end of x,
    without copying anything. If I am left with a huge amount of
    unused space, then I might decide to free it up.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu