On 16/08/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

Brad -

> As a side note, if I wanted to get really fast char append, how does
> this method sound:
> 1) In a structure (not sure if a mem_line or bufT struct), have three
> new entries
> uint current_line_num;
> uchar *current_line_buffer;
> uint current_line_alloced;
> 2) current_line_buffer points to the string data for the current line,
> it starts off at a sane size (say 80, or screen_width), and doubles in
> alloced size when it is too full.
> 3) ml_append_char (or whatever I call it), will check the target line
> number against current_line_number, if the match then
>   - append the char, possibly reallocing the current_line_buffer if we
> have run out of space
> ELSE, the edit line number and our "cached line" don't match
>   - trim the size of the current_line_buffer to match the STRLEN of the line
>   - alloc a new oversized line buffer and copy the new edit line into it
>   - append the char as above

Vim caches the last changed line, you could do something with that.
Start looking at ml_flush_line(), you can find the rest from there.

> Would this kind of optimisation be more widely useful?

Perhaps.  Changing the same line several times is not unusual.  It
mostly depends on how much code would need to be changed compared to
how much we would gain.

- Bram


Thanks for the tips, I'll test all this out and see what I can come up
with.  I also accidentally posted just to Bram, so I've included the
list in this reply.

Thanks
Brad

Reply via email to