Re: [dev] [sandy] [PATCH] VIM key bindings.
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.
Received on Fri Jul 11 2014 - 00:32:41 CEST
This archive was generated by hypermail 2.3.0
: Fri Jul 11 2014 - 00:36:16 CEST