Re: [fpc-pascal] String conversions

2019-06-28 Thread Zoë Peterson
On 6/28/2019 3:07 PM, Ryan Joseph wrote: On Jun 28, 2019, at 3:40 PM, Martok wrote: So, I would expect (and FastMM has codepaths for that), that repeated reallocations cause some form of "over-allocating" growth and most of the individual "+1" reallocs will be essentially no-ops. Interesting.

Re: [fpc-pascal] String conversions

2019-06-28 Thread Ryan Joseph
> On Jun 28, 2019, at 3:40 PM, Martok wrote: > > So, I would expect (and FastMM has codepaths for that), that repeated > reallocations cause some form of "over-allocating" growth and most of the > individual "+1" reallocs will be essentially no-ops. Interesting. How could we test this to see

Re: [fpc-pascal] String conversions

2019-06-28 Thread Martok
> Yes indeed. FPC already has an overwhelming amount of string types. As I said > though a SetCapacity option for growing would be nice (for dynamic arrays > also) because += is such a common operation. As it stands I often don’t use > dynamic arrays (and now ansistring) because of growing

Re: [fpc-pascal] String conversions

2019-06-26 Thread Sven Barth via fpc-pascal
Am 27.06.2019 um 07:10 schrieb Sven Barth: Am 26.06.2019 um 23:36 schrieb Ryan Joseph: On Jun 26, 2019, at 3:28 PM, Ben Grasset wrote: I think Ryan probably meant his own custom types. And certainly, you can do some interesting stuff with operator overloading that mostly avoids the normal

Re: [fpc-pascal] String conversions

2019-06-26 Thread Sven Barth via fpc-pascal
Am 26.06.2019 um 23:36 schrieb Ryan Joseph: On Jun 26, 2019, at 3:28 PM, Ben Grasset wrote: I think Ryan probably meant his own custom types. And certainly, you can do some interesting stuff with operator overloading that mostly avoids the normal AnsiString overhead. Here's an example.

Re: [fpc-pascal] String conversions

2019-06-26 Thread Ben Grasset
On Wed, Jun 26, 2019 at 5:36 PM Ryan Joseph wrote: > Yes indeed. FPC already has an overwhelming amount of string types. As I > said though a SetCapacity option for growing would be nice (for dynamic > arrays also) because += is such a common operation. As it stands I often > don’t use dynamic

Re: [fpc-pascal] String conversions

2019-06-26 Thread Ryan Joseph
> On Jun 26, 2019, at 3:28 PM, Ben Grasset wrote: > > I think Ryan probably meant his own custom types. And certainly, you can do > some interesting stuff with operator overloading that mostly avoids the > normal AnsiString overhead. Here's an example. Yes indeed. FPC already has an

Re: [fpc-pascal] String conversions

2019-06-26 Thread Ben Grasset
On Wed, Jun 26, 2019 at 3:28 PM Ben Grasset wrote: > I think Ryan probably meant his own custom types. And certainly, you can > do some interesting stuff with operator overloading that mostly avoids the > normal AnsiString overhead. Here's an example. >

Re: [fpc-pascal] String conversions

2019-06-26 Thread Ben Grasset
On Wed, Jun 26, 2019 at 5:48 AM Michael Van Canneyt wrote: > I second that. > > Michael. > I think Ryan probably meant his own custom types. And certainly, you can do some interesting stuff with operator overloading that mostly avoids the normal AnsiString overhead. Here's an example.

Re: [fpc-pascal] String conversions

2019-06-26 Thread Michael Van Canneyt
On Wed, 26 Jun 2019, Marco van de Voort wrote: Op 25/06/2019 om 21:58 schreef Ryan Joseph: 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

Re: [fpc-pascal] String conversions

2019-06-26 Thread Marco van de Voort
Op 25/06/2019 om 21:58 schreef Ryan Joseph: 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

Re: [fpc-pascal] String conversions

2019-06-25 Thread Ryan Joseph
> On Jun 25, 2019, at 3:55 PM, Marco van de Voort > wrote: > > 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

Re: [fpc-pascal] String conversions

2019-06-25 Thread Marco van de Voort
Op 2019-06-25 om 21:12 schreef Ryan Joseph: On Jun 25, 2019, at 2:16 PM, Jonas Maebe 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

Re: [fpc-pascal] String conversions

2019-06-25 Thread Jonas Maebe
On 25/06/2019 21:12, Ryan Joseph wrote: > > 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? Strings always contain

Re: [fpc-pascal] String conversions

2019-06-25 Thread Ryan Joseph
> On Jun 25, 2019, at 2:16 PM, Jonas Maebe 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

Re: [fpc-pascal] String conversions

2019-06-25 Thread Ryan Joseph
> On Jun 25, 2019, at 2:16 PM, Jonas Maebe wrote: > > On 25/06/2019 20:15, Ryan Joseph wrote: >> I’m making some string helper functions and using ansistring as inputs (in >> case there are longer strings than 255 chars). What happens when you pass a >> short string as an ansistring? Does

Re: [fpc-pascal] String conversions

2019-06-25 Thread Jonas Maebe
On 25/06/2019 20:15, Ryan Joseph wrote: > I’m making some string helper functions and using ansistring as inputs (in > case there are longer strings than 255 chars). What happens when you pass a > short string as an ansistring? Does the compiler have to allocate a new > ansistring or can it do

[fpc-pascal] String conversions

2019-06-25 Thread Ryan Joseph
I’m making some string helper functions and using ansistring as inputs (in case there are longer strings than 255 chars). What happens when you pass a short string as an ansistring? Does the compiler have to allocate a new ansistring or can it do some smart optimization? Regards, Ryan