4 ms·
Not really, it's a commonly used scheme. Read on gap buffers: https://en.wikipedia.org/wiki/Gap_buffer https://en.wikipedia.org/wiki/Gap_buffer It's really a
by yaantc 7y ago
Not really, it's a commonly used scheme. Read on gap buffers:
https://en.wikipedia.org/wiki/Gap_buffer https://en.wikipedia.org/wiki/Gap_buffer
It's really an array with a gap at the cursor location. Used by emacs and others for decades.
- pkaye 7y agoHow big can file can a gap buffer be used on until it starts to slow down with current hardware?
- azhenley 7y agoIn the article, I listed a rope, gap buffer, and piece table as potential solutions instead of "just an array".
- smaddox 7y agoBut that's massively better than just an array. It changes the time complexity from O(char_inserts x file_len) to O(cursur_move x file_len), which is likely a couple orders of magnitude better.
- jakear 7y agoVSCode uses a JS piece tree, which allows it to be faster* at manipulating large files than Sublime’s native code implementation. https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation https://code.visualstudio.com/blogs/2018/03/23/text-buffer-r... *or at least competitive with. I’ve measured it to be faster but I’ve heard others have had different experiences
- ben-schaaf 7y agoFrom a quick read it's actually pretty close to exactly what Sublime Text does. Source: Worked on that code at sublime recently.
- banachtarski 7y agoThat's not a single array though (per the OP's point)
- tgv 7y agoThat's not "just an array".