[fpc-pascal]2 questions on ansistrings

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Aug 28 00:53:32 CEST 2003

On Wed, 27 Aug 2003, Mark Emerson wrote:

> 1. If a segment is deleted from an ansistring, e.g. ...
> s := 'abcdefghijklmnop';
> delete (s, 5, 6);
> yielding s = 'abcdelmnop'
> ...does the system "shift" the 'lmnop' to the left, or does the string
> get hooked together with pointers, thus saving much time with long strings?

It is shifted. Hooked together would maybe make 'delete' faster, but
would considerably slow down other operations.

But the memory is not reallocated in this case, unless the string had a
reference count of 2.

And the shift is done using a 'Move' instruction, which is highly

> 2. Is there any documentation yet of the ansistring internals?  If not,
> what file contains the source?

The memory layout is documented in the programmer's guide:

Memory Issues
 + Data Formats
   + String types
     + Ansistring types

The source is rtl/inc/astrings.inc


More information about the fpc-pascal mailing list