And yet, search-and-replace on big files takes seconds.
I can grep through half my file system in seconds. What do you measure?
Re:Text Showdown: Gap Buffers vs. Ropes
by PH95VuimJjqBqy on Tuesday October 10, 2023 @10:04AM
(#37832258)
I don't know this authoritatively, but I believe vim uses a simple array internally. And it works well.
Every time this point comes up in the design of text editors, I feel compelled to mention that memory bandwidth is dozens of GB/s on modern hardware; even when it was only a few MB/s a few decades ago, text editors that used a single contiguous buffer (not even a gap) were very common and no one complained about their speed. Indeed, the benchmarks in this article confirm that.
As another popular article that's often submitted here says: computers are fast --- very fast for human timescales, and in particular manipulating text of humanly-encountered sizes.
There's a lot of dogma around advanced text editor structures and what is "optimal", and IMHO a lot of that is totally unneeded accidental complexity created by those more interested in theoretical daydreaming than real-world solutions. Thus, I think even a gap buffer is "overkill", and a single "gapless" buffer is really sufficient. Don't overthink things.