Sign in Join

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

Mailing lists / lazarus / 2003-04

Speaking of TMemo and RH9...

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Marc Weustink
to Tom Lisjac: Thanks for the reply! The following provides exactly the same slow load (50+…
Show quoted text 37 lines
On 17 Apr 2003, Tom Lisjac wrote: > > > > It works... but I can't help but wonder if there's a more elegant way to > > > make TMemo go? :) > > > > The TTextString (or whatever is used) implementation of TMemo.Lines > > should respect the beginupdate/endupdate calls: Changes should not > > be applied till the updatecount reaches zero again. > > Thanks for the reply! > > The following provides exactly the same slow load (50+ seconds)...so I > wondered if beginupdate and endupdate had been implemented in TMemo: > [...] > The workaround is perfectly acceptable... but the behavior of the lines > property seemed a little odd so I thought I'd mention it. I have checked the TMemoStrings stuff. What can I say ? I think that whoever wrote it should rethink his design. Filling up a memo with a lot of lines will become slower with a factor N^2 the way it is done now: This code TempStrings := TStringList.Create; CurText := FMemo.Text; TempStrings.Text := CurText; Cnt:=TempStrings.Count; Is executed once per line added. This is not acceptable in my opinion, as the statement TempStrings.Text := CurText; is repeating the operation that is actually being performed.

A while ago it was discussed, and the TStrings in TMemo will be replaced by a Text based TStrings. If it is OK, someone is working on that.

Marc

Reply by email

Tom Lisjac
to Michael Van Canneyt: The TTextString (or whatever is used) implementation of TMemo.Lines should respect the…
Show quoted text 6 lines
> It works... but I can't help but wonder if there's a more elegant way to > make TMemo go? :) The TTextString (or whatever is used) implementation of TMemo.Lines should respect the beginupdate/endupdate calls: Changes should not be applied till the updatecount reaches zero again.

Thanks for the reply!

The following provides exactly the same slow load (50+ seconds)...so I wondered if beginupdate and endupdate had been implemented in TMemo:

        memo1.lines.beginupdate; // takes  to load
        try
          memo1.lines.loadfromfile(opendialog1.filename)
        finally
          memo1.lines.endupdate
        end;

This is also just as slow:

        x:=TStringlist.create;
        x.loadfromfile(opendialog1.filename);
        memo1.lines.beginupdate;
        try
          memo1.lines.text:=x.text;
        finally
          memo1.lines.endupdate;
          x.free
        end;

It seems that any operations using TMemo's Lines:TStrings property are slow (with or without beginupdate and endupdate). Using Text:Widestring, however, loads TMemo in less then a second:

        x:=TStringlist.create;
        try
          x.loadfromfile(opendialog1.filename);
          memo1.text:=x.text;
        finally
          x.free
        end

The workaround is perfectly acceptable... but the behavior of the lines property seemed a little odd so I thought I'd mention it.

Best regards,

-Tom

Reply by email

Unknown author
to Tom Lisjac
Tom Lisjac wrote 13 lines
> > It works... but I can't help but wonder if there's a more elegant way to > > make TMemo go? :) > > The TTextString (or whatever is used) implementation of TMemo.Lines > should respect the beginupdate/endupdate calls: Changes should not > be applied till the updatecount reaches zero again. Thanks for the reply! The following provides exactly the same slow load (50+ seconds)...so I wondered if beginupdate and endupdate had been implemented in TMemo:

[...]

The workaround is perfectly acceptable... but the behavior of the lines property seemed a little odd so I thought I'd mention it.

I have checked the TMemoStrings stuff.
What can I say ?

I think that whoever wrote it should rethink his design. Filling up a memo with a lot of lines will become slower with a factor N^2 the way it is done now:

This code
    TempStrings := TStringList.Create;
    CurText := FMemo.Text;
    TempStrings.Text := CurText;
    Cnt:=TempStrings.Count;

Is executed once per line added. This is not acceptable in my opinion, as the statement

  TempStrings.Text := CurText;

is repeating the operation that is actually being performed.

Michael.

Reply by email

Tom Lisjac

I've noticed some significant speed differences between Mandrake 8.2 and RH9 when loading TMemo from a text file. On RH9, it took 55 seconds for "memo1.lines.loadfromfile('/tmp/test')" to load 1400 lines like this:

4Suite-0.11.1-13.i386.rpm
abiword-1.0.4-2.i386.rpm
acl-2.2.3-1.i386.rpm
adjtimex-1.13-6.i386.rpm
...

The same binary loaded the same text file on Mandrake 8.2 in 3 seconds. Both machines are 1.6 Ghz P4's with a gigabyte of ram.

To make the problem go away, I did the file i/o with a separate stringlist... then assigned the text properties. This loaded and saved the file instantly on both systems:

 x:=TStringlist.create;
 x.loadfromfile('/tmp/test');
 memo1.text:=x.text
 ...
 x:=TStringlist.create;
 x.text:=memo1.text
 x.savetofile('/tmp/test');
 ...

It works... but I can't help but wonder if there's a more elegant way to make TMemo go? :)

Best regards,

-Tom

Reply by email

Michael Van Canneyt
to Tom Lisjac
Tom Lisjac wrote 30 lines
I've noticed some significant speed differences between Mandrake 8.2 and RH9 when loading TMemo from a text file. On RH9, it took 55 seconds for "memo1.lines.loadfromfile('/tmp/test')" to load 1400 lines like this: 4Suite-0.11.1-13.i386.rpm abiword-1.0.4-2.i386.rpm acl-2.2.3-1.i386.rpm adjtimex-1.13-6.i386.rpm ... The same binary loaded the same text file on Mandrake 8.2 in 3 seconds. Both machines are 1.6 Ghz P4's with a gigabyte of ram. To make the problem go away, I did the file i/o with a separate stringlist... then assigned the text properties. This loaded and saved the file instantly on both systems: x:=TStringlist.create; x.loadfromfile('/tmp/test'); memo1.text:=x.text ... x:=TStringlist.create; x.text:=memo1.text x.savetofile('/tmp/test'); ... It works... but I can't help but wonder if there's a more elegant way to make TMemo go? :)

The TTextString (or whatever is used) implementation of TMemo.Lines should respect the beginupdate/endupdate calls: Changes should not be applied till the updatecount reaches zero again.

Michael.

Reply by email