CudaText: ed.set_text_line is of time complexity O(n)

i’m trying to improve ExTerminal performance. noticed how adding more lines to memo is slowing it down.

as far as i know, adding lines to the end of memo (or adding elements to end of an array) must be fast, i.e. complexity O(1).

to prove it i wrote a simple plugin cuda_complexity_plot @Alexey-T, you can install it and run command: Complexity Plot: Test 8 ...

and i found the line that is slowing down this API:

https://github.com/Alexey-T/CudaText/blob/3d7b55da2b04e1c0a86564fa806f3e48211e5c92/app/proc_editor.pas#L2472

with this line it’s O(n) and graph looks like this:

1

without - it’s O(1) and graph looks like this:

2

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 26 (26 by maintainers)

Commits related to this issue

Most upvoted comments

just fixed. stupid regress w/o enough testing. sorry.

Fix made

Screenshot from 2024-01-19 11-13-58

now let’s test usual work for possible regressions.