kryslt / KControls

Free components for Delphi and Lazarus, this is the main repository maintained by the original author.
BSD 3-Clause Clear License
59 stars 32 forks source link

TKMemo: rendering speed is so slow #56

Open bird00101011 opened 4 months ago

bird00101011 commented 4 months ago

When I insert multiple texts, or when the text content is too large, the insertion efficiency becomes very low

kryslt commented 4 months ago

No algorithms are implemented to improve performance for large documents. Each change to a document results in a complete recalculation of all document metrics. However, for most documents (<50 A4 pages), this response should be reasonably short.

bird00101011 commented 4 months ago

I have use this code fixed it.

try
    KMemo1.Blocks.LockUpdate;
    while BlockNo < Kmemo1.Blocks.Count do begin
        SomeCrazyProcedure(KMemo.Blocks.Items[BlockNo]);
        inc(BlockNo);
    end
finally
    KMemo1.Blocks.UnlockUpdate;
end;

https://wiki.lazarus.freepascal.org/KControls/KMemo_notes [Locking chapter].

Thanks for ur reply.

kryslt commented 4 months ago

Yep, I thought you were talking about the slowness of Unlockupdate. This method is known to be slow for large documents. In certain situations (like typing new text) there should not be the need to recalculate entire document metrics all the time. These are the algorithms I was talking about, which are not implemented yet.