3 ms·
An array and nothing else? It very quickly stops making sense to copy the entire tail section of the file every time the user inserts text in the middle.
by wavemode 3y ago
An array and nothing else? It very quickly stops making sense to copy the entire tail section of the file every time the user inserts text in the middle.
- userbinator 3y agoA conservative estimate for memmove() speed on a computer from even a decade ago would be 1GB/s. That's 1ms to move 1MB. All humans won't notice a latency below 10ms.
- kragen 3y agothis is true, and a good point; the machine i'm typing this on is closer to 20 gigabytes a second. but, for example, if i refill a longish paragraph in emacs, it might easily do dozens of insertions; if i indent or outdent a block of code, it might do hundreds. it's easy to imagine a situation where i have a 13-megabyte mail.log open in emacs and want to do a search-and-replace to reduce the noise level in it, maybe making 12895 edits. this currently takes less than a second (emacs uses a gap buffer), but if each of those edits took 6 milliseconds it would have been a minute or two
- ehaliewicz2 3y agoIf it was an issue, and a simple gap buffer isn't fast enough, you could do a linked list of gap buffers. Would still be pretty simple, and probably very fast.