TMemo is sick slowly when working with a lot of lines

I have 100,000 lines in TMemo. I want to do something like:

 for i:= 0 to Memo.Lines.Count-1 do
  Memo.Lines[i]:= SomeTrim(Memo.Lines[i]);

but the speed is 0.5 lines per second!

After adding BeginUpdate / EndUpdate I do not see speed improvement.

 Memo.Lines.BeginUpdate;
 for i:= 0 to Memo.Lines.Count-1 do
  Memo.Lines[i]:= SomeTrim(Memo.Lines[i]);
 Memo.Lines.EndUpdate;

My question is: why doesn't BeginUpdate / EndUpdate help?

+4
source share
1 answer

TStrings.BeginUpdate/EndUpdatewill ban events OnChangingand OnChanged. It does not affect the internal processing of changes to the content itself.

TMemo.Linesimplemented TMemoStrings, which stores text content in the Window control itself. So BeginUpdate/EndUpdatehere is useless.

, TStringList Text TMemo TStringList . Text TMemo.

  lst := TStringList.Create;
  try
    lst.Text := Memo1.Lines.Text;
    for I := 0 to lst.Count - 1 do begin
      lst[I] := SomeTrim(lst[I]);
    end;
    Memo1.Lines.Text := lst.Text;
  finally
    lst.Free;
  end;

.. Assign Text Memo: Assign - Text TMemoLines. Getter Setter Windows WM_GETTEXT/WM_SETTEXT, Assign EM_GETLINE EM_LINEINDEX, EM_SETSEL, EM_LINEELENGTH EM_REPLACESEL . , 600 Text Assign 11 !

+10

Source: https://habr.com/ru/post/1688339/


All Articles