2 ms·
use a gap buffer: https://en.wikipedia.org/wiki/Gap_buffer https://en.wikipedia.org/wiki/Gap_buffer. For scaling large docs, you can do a linked list of gap b
by mikeeeek 7y ago
use a gap buffer: https://en.wikipedia.org/wiki/Gap_buffer https://en.wikipedia.org/wiki/Gap_buffer.
For scaling large docs, you can do a linked list of gap buffers and avoid re-allocs of large buffers.
Super simple, efficient enough for most “i wrote my own text editor”, can always plug in a more complex structure later.
Author’s implementation will drag down if you have very long lines (e.g., transpiled JS).