On July 11, 2014 1:32:41 AM EEST, Dimitris Papastamos <s...@2f30.org> wrote: >On Fri, Jul 11, 2014 at 01:26:38AM +0300, Dimitris Zervas wrote: >> But how are you going to deal with lines longer than the capacity of >a line? or buffers longer than the capacity of buffer? > >You have to resize the buffer. > >There are some clever ways to expand the buffer in O(sqrt(N)) >extra space (assuming you actually want to preallocate it in advance). > >The common solution is to double the capacity and realloc(). > >Another thing you can do is to only preallocate a fixed size buffer >and add to a list of buffers. Every time you cross block boundary, you >alloc >a new buffer and attach it at the end of your list. > >There are many ways to do this, I'd go for the simplest approach in >terms of code >readability and stop worrying about performance. > >If it is slow or memory hungry, it can be fixed later incrementally. Hmm, well yes... One-line code was always a problem (ex. machine generated code). Realloc is indeed the simplest approach I can think of, but I want to deal with it and keep the code at a sane condition.
First of all, we haven't even agree in which data structure will we use. Buffer gap, piece table, or pointer array? I have no idea of the first 2 (and my English fail me, as I can't understand a lot of the pdfs given)