[fpc-pascal] Feature announcement: Dynamic array extensions

Sven Barth pascaldragon at googlemail.com
Fri May 25 10:57:49 CEST 2018


Ryan Joseph <ryan at thealchemistguild.com> schrieb am Fr., 25. Mai 2018,
10:24:

>
>
> > On May 25, 2018, at 3:18 PM, Michael Van Canneyt <michael at freepascal.org>
> wrote:
> >
> > I'm guessing you are not using strings either then, for performance
> reasons ? Because exactly the same happens there.
>
> really? I had a collection class with a dynamic array for the storage and
> that’s when I got the high CPU usage in the thread safe stuff. I replaced
> the storage with a pointer to a block of memory which I managed myself and
> the problem went away. I just wanted to a dynamic array that was fast,
> minimal and could append elements.
>
> I use lots of strings but I never had that problem. Are strings reference
> counted like dynamic arrays? I thought a string was just an array of 255
> chars.
>

ShortString is limited to 255 chars. AnsiString and UnicodeString don't
have that limitation and they are reference counted just like dynamic
arrays.

The type of "String" depends on the current settings:
- $H-: String = ShortString (this is the default for all modes except the
Delphi ones)
- $H+ and "$modeswitch unicodestrings-": String = AnsiString (or
AnsiString(CP_ACP) to be precise) (this is the default for mode Delphi)
- $H+ and "$modeswitch unicodestrings+": String = UnicodeString (this is
the default for mode DelphiUnicode)

If I had to guess you were probably doing something with the arrays they
weren't designed for. :/

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180525/9c63f48a/attachment.html>


More information about the fpc-pascal mailing list