Re: Faster way of making long string?



Hello J

J French wrote:
On Sun, 24 Apr 2005 19:51:01 +0200, Ekkehard Domning <edo@xxxxxxxx>
as You see, Ian made a test and shows that the stringlist method is running at double speed as his approach. I would define "inefficiency" a bit different.

Check Chris Willig's example - and that could be made faster by aggressive increasing of the buffer
size (eg: Len := Len * 2 )

Agree. I posted a fast example too, please take a look there.

At the end of the discussion comes the question about the code. Should the code be "fast" or "maintainable".
It should be both
- but even more important, it should not be obscure

I have seen very fast code, but nobody could understand. So if an error occour it becomes "obscure". So agree too.


- creating a TStringList when you want one long string is 'indirect'

True, but the way is easy. Make strings from all numbers, than build one long string from the small strings. Yes, there is a lot work on the heap in the background, and yes there is nearly twice as much memory needed than in the fast example.


This is not meant to be personal, but I have noticed that a lot of
Delphi coders are not really that familiar with working with Strings.
- because they are really a fairly recent addition to the language
they should become fammilar, its really a very good choice

Where you would use a TStringList I would probably use a dynamic array
also not very old stuf :-)
or just one long string.
....

Obviously, I have a large library of string manipulation routines that
started life well before Delphi - in DOS BASIC and ASM
I agree that old handy tools could be a very comfortable. A new tool needs unpacking, reading instruction, you have to go in the work room find a cable, etc. In the meantime the old tool has finished the work :-)

Best regards
Ekkehard Domning
.