[fpc-pascal] Re: Access violation that I do not understand while creating a class instance
Jürgen Hestermann
juergen.hestermann at gmx.de
Mon Jan 23 17:59:07 CET 2012
ik schrieb:
> PChar is an array like approach. AnsiString, is a record based
pointer. It uses more memory, and provide a bit overhead for the same thing.
> At least on theory. I would love to learn that it's not the case.
AnsiString stores and keeps track of the string length and this has many
advantages:
*) If you need the length of a Pchar string you always need to count
character by character (until #0). This is very slow. Ansistring has it
available directly.
*) If you compare two strings for identity you can first compare
lengths. If different then strings are different too. Not possible with
pchar.
*) You can store #0 in AnsiStrings (not possible with pchar because it
indicates the end of the string).
*) You can access the last string character directly by using the
length. With pchar you have to iterate on all characters.
More information about the fpc-pascal
mailing list