?
Solved

Speedup Richedit copy

Posted on 2000-02-23
7
Medium Priority
?
418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 80 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 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