Re: Interesting Experiment With String/Sequence Slicing
- Posted by Robert Craig <rds at RapidEuphoria.com> Aug 16, 2001
- 450 views
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