Solved

Speedup Richedit copy

Posted on 2000-02-23
7
379 Views
Last Modified: 2013-11-22
I need to copy one richedit's lines to another one.

Richedit2.lines:=Richedit1.lines;

But if the first RE content is a bit long(60K, even)  then The cursor starts to blink uglily( :) ) and it takes alota time.

If I do the thing in this way:

for i:=0 to richedit1.lines.count-1 do
  richedit2.lines.add(richedit1.lines[i]);

It doesn't speed up anyway.....

plz help
0
Comment
Question by:duke_n
  • 5
  • 2
7 Comments
 
LVL 6

Expert Comment

by:edey
ID: 2551281
what happens if you use TRichEdit.assign, or contain the copy with calls to richEdit.lines.beginUpdate/richEdit.lines.endUpdate?


GL
Mike
0
 
LVL 1

Author Comment

by:duke_n
ID: 2551338
Assign lasts the same time.
Y'know, that's weird: even the loading of the original file was MUCH faster(and it involves HDD which supposta be slower than RAM).

I don't understand whatcha mean with Begin and EndUpdate. can ya bring some code[please]?
0
 
LVL 6

Expert Comment

by:edey
ID: 2551359
the above should suggest TRichEdit.lines.assign, not TRichEdit.assign.  

Also, a quick check (using windows.pas as a test file) found that richEdit2.txt := richEdit1.text was *MUCH* faster ie.

copying lines = 14440ms
assigning lines = 14990ms
begin/end update = 14500ms
copying text = 160ms


GL
Mike
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 6

Expert Comment

by:edey
ID: 2551380
>Assign lasts the same time.

yeah, I though it would be faster too hmmm.

>Y'know, that's weird: even the loading
>of the original file was MUCH faster
>and it involves HDD which supposta be
>slower than RAM).

I believe this is due to the control being redrawn while it is updated

>I don't understand whatcha mean with
>Begin and EndUpdate. can ya bring some
>code[please]?

the lines property (a TStrings desc) has teo methods beginUpdate & endUpdate.  If you need to make changes to the text (many insertions/deletions etc.) "bracketing" them with these two calls can significantly improve performance.


Anyway, see above comment as to the text solution


Gl
Mike
0
 
LVL 6

Accepted Solution

by:
edey earned 20 total points
ID: 2551385
this is the code i used to test the above mentioned "solutions":


procedure TForm1.Button1Click(Sender: TObject);
var
   t : TTimeStamp;
begin
     richEdit2.lines.clear;
     t := dateTimeToTimeStamp(time);
     richEdit2.lines := richEdit1.lines;
     caption := intToStr(dateTimeToTimeStamp(time).time-t.time);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   t : TTimeStamp;
begin
     richEdit2.lines.clear;
     t := dateTimeToTimeStamp(time);
     richEdit2.lines.assign(richEdit1.lines);
     caption := intToStr(dateTimeToTimeStamp(time).time-t.time);
end;

procedure TForm1.Button3Click(Sender: TObject);
var
   t : TTimeStamp;
begin
     richEdit2.lines.clear;
     t := dateTimeToTimeStamp(time);
     richEdit2.lines.beginUpdate;
     richEdit2.lines := richEdit1.lines;
     richEdit2.lines.endUpdate;
     caption := intToStr(dateTimeToTimeStamp(time).time-t.time);
end;

procedure TForm1.Button4Click(Sender: TObject);
var
   t : TTimeStamp;
begin
     richEdit2.lines.clear;
     t := dateTimeToTimeStamp(time);
     richEdit2.text := richEdit1.text;
     caption := intToStr(dateTimeToTimeStamp(time).time-t.time);
end;



GL
Mike
0
 
LVL 1

Author Comment

by:duke_n
ID: 2554141
Now I see!!!!!

I tried to copy the RE.Lines.
I didn't see it has Re.Text.

You've been most helpful, sonny :)
0
 
LVL 6

Expert Comment

by:edey
ID: 2554670
Glad to be of service :)

GL
Mike
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now