[fpc-pascal] String conversions

Marco van de Voort fpc at pascalprogramming.org
Tue Jun 25 21:55:57 CEST 2019


Op 2019-06-25 om 21:12 schreef Ryan Joseph:
>
>> On Jun 25, 2019, at 2:16 PM, Jonas Maebe <jonas at freepascal.org> wrote:
>>
>> It has to allocate a new ansistring.
> Another question: if I do "s += c” will the string reallocate memory for 1 character or is there an exponential growing function? If it does grow by one character at a time how can I reserve a certain capacity in advance?
An exponential growing function applied to all strings would have many 
worse case behaviours, where it would eat up heaps of memory for 
nothing. This is why it is better to have the programmer indicate it is 
a growing string some how (or have a separate type, like TStringBuilder 
mentioned by Jonas)


More information about the fpc-pascal mailing list