On Thu, Dec 11, 2008 at 1:29 AM, H. Sasse <[EMAIL PROTECTED]> wrote: > >> But (and correct me if I'm wrong) it doesn't avoid the problem that >> for each concatenation the contents of the strings are copied into a >> new one. > > Yes, it does. By keeping them on a stack, only the top elements get > copied until they are bigger than the one below, to which they get > joined. So if your lines are 1000, 500, 100, chars long, and the next > is 200 chars long, that will be joined to the 100 -> 300, which is still > smaller than 500, so that line doesn't get copied yet. Add another 250 > char line, 250 + 300 = 550, which is bigger than 500, so that gets added > on the front 500 + 550, giving a stack of: 1000 char line, then a 1050 > char line. So 1050 > 1000 so those get joined to give the 2050 char line. > > Currently you'd have 1000 + 500 giving one copy, then 1500 + 100 giving > another large copy, then 1600 + 200 giving another large copy, then 1800 > + 250, giving the 2050. Doing the small ones first is more efficient. >
Oh, I get it now ! I agree that it is quite elegant. Thanks for this detailed explanation. -- MatÃas Larre Borges --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---