Strings

String are probably the most used data type in Delphi. They also have a very interesting implementation, optimized for fast execution. To be exact, AnsiString (with all its variations) and UnicodeString (also known as string) are optimized. The WideString type is implemented in a different manner. As short strings (declarations like string[17]) are only used for backwards compatibility, I won't discuss them in this book.

Let's deal with the more widely used AnsiString and UnicodeString first. A data of such type is represented with a pointer to a block, allocated from the memory manager. If a string is empty, this pointer will be nil (which is at the CPU level represented with number zero) and if a string is not empty, it will point ...

Get Delphi High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.