On Wed, Jul 09, 2014 at 05:00:45PM -0400, Carlos Torres wrote: > Hey Marc, > > On Wed, Jul 9, 2014 at 4:42 PM, Marc André Tanner <m...@brain-dump.org> wrote: > > On Wed, Jul 09, 2014 at 09:14:16PM +0200, Rafa Garcia Gallego wrote: > > ...this includes > > a design based on piece tables rather than the double linked list approach > > taken by sandy. > > What are the performance benefits of having the piece table instead?
Loading a document does not depend on the number of lines or the file size. In general the performance depends on the number of edits made. What I find interesting is that it is a persistent data structure, that is you only ever append text, never move or delete it which at least in theory is nice for undo/redo. On the down side, the implementation is obviously more complex and since the current text might not be stored contiguously things like search and replace might become a bit tricky. I've recently been reading about Project Oberon whose text subsystem is built on piece tables. That is how I became interested and did some further investigations. The technique has been used before in a number of text editors such as Bravo (from Xerox PARC), Lara and even Word. However I'm not aware of a modern, console based, text editor using this approach. Pointers welcome. I guess it also depends on what kind of assumptions you make about your documents. If you only ever want to work with documents of a couple hundred lines of 80 columns (i.e. source code) it might be overkill. But for me an editor which sucks less should work fine with arbitrary input. Anyway if time permits I will give it a try and play around a bit. Marc -- Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0