Lee Naish wrote:

> The "J" command seems to have a complexity bug when given a large numeric
> argument, eg 100000J
> 
> eg:
> 
> %  yes | head -100000 > vimtest
> %  time vim vimtest
> 
> <Joined all lines using 99999J>
> 
> 17.2u 0.0s 2:29.74 11.5% 0+0k 0+10232io 0pf+0w
> % yes | head -200000 > vimtest
> %  time vim vimtest
> 
> <Joined all lines using 199999J>
> 
> 68.8u 0.4s 1:41.22 68.3% 0+0k 0+39648io 0pf+0w
> 
> ie, doubling the number of lines increased the runtime by a factor of 4
> exactly - seems like there is a O(N^2) component to the algorithm.

This is a known problem.  It works like doing J 100000 times.  So near
the end you are appending a short line to a very long line, copying
everything into newly allocated memory.

Allocating all the memory at once is a bit complicated.  Perhaps an easy
solution would be to join two lines at a time.

> I've checked out a copy under SVN, found the O(N^2) code and hacked up
> a possible fix, but haven't been able to test it because I have some
> shared library problem - I can create vim7/src/vim but when I run it
> (even the original version) I get:
> 
> ld.so.1: vim: fatal: libintl.so.3: open failed: No such file or directory
> Killed

Make sure you do "make distclean" before building and check the
configure output for any trouble.

-- 
TIM: To the north there lies a cave,  the cave of Caerbannog, wherein, carved
     in mystic runes, upon the very living rock, the last words of Olfin
     Bedwere of Rheged make plain the last resting place of the most Holy
     Grail.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui