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

<SNIP>

I understand.  It would be a bit more efficient if the new, empty line
that you add when a newline is encountered already has room for a
certain number of characters.
Ah, I see.  True, but since I don't know the code base that well I
didn't want to touch too much code all over the place.


> > Also, for appending to a different line than before you copy the line
> > twice.  You can avoid that by using vim_strnsave() instead of
> > vim_strsave() and reserving space for new characters right away.
>
> Yes, this is a slight inefficiency.  The main reason that I did this
> was that I wanted all the code to do with re-allocation in the same
> place, ie the next if block.  Looking at the code again now, the
> solution is probably to not copy in the "cache miss" code, where we
> flush - just do
> curbuf->b_ml.ml_line_ptr = ml_get(lnum);

I suppose that should work (didn't look at it carefully).

I might have a look later if this code can be used in certain
situations.  That should make some operations work faster, e.g. pasting
a large chunk of text into a terminal emulator.

I think it will work from the quick glance over it.  I can test it
more throughly tonight.  I'd love it if I made an actually useful
contrib to Vim - I love this editor, thanks for writing it!

Brad

Reply via email to