3 ms·
This is an interesting list. I'd add hashing and hash tables to the list. There are lots of interesting variations of these as well. I would put hash tables ah
by todd8 4y ago
This is an interesting list. I'd add hashing and hash tables to the list. There are lots of interesting variations of these as well.
I would put hash tables ahead of piece tables because of their generality. For text editors I've always thought that gap buffers were so straightforward that ropes and piece tables seemed like extra unnecessary work. I see that VS Code uses piece tables so perhaps someone can explain the performance differences to me.
I've never sat down and benchmarked various implementations of text buffers. However, it seems to me that memmove(3) on modern processors would be so fast that moving a buffer gap on even a 1GB file wouldn't be perceptible, and in return operations over the whole buffer like string searching or parsing would be much more efficient in a gap buffer because the program could count on the buffer being in contiguous memory locations (after closing the gap). In buffers implemented using a part table or ropes, every character access involves extra layers of indirection. Furthermore, gap buffers are going to be more cache friendly for the way that most editing operations take place in a text editor.
Perhaps someone that has actually done some comparisons could enlighten me.
- TYMorningCoffee 4y agoI think the author excluded hashing because it is too well known.
- todd8 4y agoThat makes sense, thanks.
- peterfirefly 4y agoPiece tables give you fast and easy undo.