[fpc-pascal] splitting string into array

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Jul 12 09:30:49 CEST 2007



On Wed, 11 Jul 2007, L wrote:

> > > > Wouldn't this function be a candidate for crawling into the 'strutils'
> > > > unit?
> > >
> > > Probably, but I would change the interface:
> > >
> > > function Split(const str: string; const separator: string; var Res : array
> of
> > > string) : Integer;
> > >
> > > So the function returns the number of elements in the array.
> > > The function could also use some speedup. Deleting the parts
> > > which are no longer needed causes a lot of memory fragmentation.
> 
> > I'd second your opinion about the interface, but regarding speedup and
> > memory fragmentation makes me think.
> >
> > For speed I'd need some hints, what technique would be faster/fastest?
> 
> [HUMOR ON]
> 
> This is not good. All you asked for was a clean function that did a job.
> Then you had some people come in and *assume that there was a bottleneck* in
> your application, which was never indeed ever stated.

I appreciate the humor :-)

But for the record:

I never assumed or said that there is a bottleneck in his application. 
I said that for inclusion in the RTL, the speedup would be needed, 
as the RTL is used in all kinds of situations, not only in his application.

Can you, BTW, explain the reference to Knuth ? I know who Donald Knuth is, 
but fail to see the link... ? (lack of culture on my part, I assume...)

Michael.



More information about the fpc-pascal mailing list