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.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to