Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-03

TStringList vs TTextStrings vs whatever

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Andrew Haines started implementing a new TStrings descendant for use as internal storage for fpGUI's Memo component (optimized for speed). This got me curious as to why many developers don't use TStringList itself. Look around and then also at LCL's TMemo, I noticed Mattias seems to have had the same idea, implementing his own descendant class called TTextStrings. Abstract from the unit (textstrings.pas) header:

----------------------
TTextStrings is a TStrings descendant that is optimized for handling the complete text as whole (instead of as line by line as in TStringList).
----------------------

It seems a lot of developers are not happy with TStringList. What's the actual downside of using TStringList for internal storage in a text component like Memo or ListBox? Performance? If so, why don't we _fix_ the implementation in TStringList itself, instead of everybody creating their own descendants?

Yes, LCL's TMemo does currently use TStringList for internal storage, but clearly Mattias did at some stage think of using TextStrings as the commented code shows.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Mattias Gaertner
to Graeme Geldenhuys
Show quoted text 24 lines
Hi, Andrew Haines started implementing a new TStrings descendant for use as internal storage for fpGUI's Memo component (optimized for speed). This got me curious as to why many developers don't use TStringList itself. Look around and then also at LCL's TMemo, I noticed Mattias seems to have had the same idea, implementing his own descendant class called TTextStrings. Abstract from the unit (textstrings.pas) header: ---------------------- TTextStrings is a TStrings descendant that is optimized for handling the complete text as whole (instead of as line by line as in TStringList). ---------------------- It seems a lot of developers are not happy with TStringList. What's the actual downside of using TStringList for internal storage in a text component like Memo or ListBox? Performance? If so, why don't we _fix_ the implementation in TStringList itself, instead of everybody creating their own descendants? Yes, LCL's TMemo does currently use TStringList for internal storage, but clearly Mattias did at some stage think of using TextStrings as the commented code shows.

I'm happy with TStringList. It should stay as an array of strings. But in some cases you want a text as single string and only occasionally access its lines. It's just a matter of optimization. You can not optimize for both.

About TMemo:
Nowadays every widgetset uses its own optimized TStrings descendant, so no need for TTextStrings.

But a TTextStrings is needed in some cases.

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote 5 lines
I'm happy with TStringList. It should stay as an array of strings. But in some cases you want a text as single string and only occasionally access its lines. It's just a matter of optimization. You can not optimize for both.

Ok, thanks for explaining... :)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email