To: vim_dev@googlegroups.com Subject: Patch 8.1.1439 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1439 Problem: Json_encode() is very slow for large results. Solution: In the growarray use a growth of at least 50%. (Ken Takata, closes #4461) Files: src/misc2.c *** ../vim-8.1.1438/src/misc2.c 2019-05-28 23:08:12.068648696 +0200 --- src/misc2.c 2019-06-01 14:31:53.506164187 +0200 *************** *** 2057,2062 **** --- 2057,2069 ---- { if (n < gap->ga_growsize) n = gap->ga_growsize; + + // A linear growth is very inefficient when the array grows big. This + // is a compromise between allocating memory that won't be used and too + // many copy operations. A factor of 1.5 seems reasonable. + if (n < gap->ga_len / 2) + n = gap->ga_len / 2; + new_len = gap->ga_itemsize * (gap->ga_len + n); pp = vim_realloc(gap->ga_data, new_len); if (pp == NULL) *** ../vim-8.1.1438/src/version.c 2019-06-01 14:15:49.535433551 +0200 --- src/version.c 2019-06-01 14:33:04.925784267 +0200 *************** *** 769,770 **** --- 769,772 ---- { /* Add new patch number below this line */ + /**/ + 1439, /**/ -- Proof techniques #2: Proof by Oddity. SAMPLE: To prove that horses have an infinite number of legs. (1) Horses have an even number of legs. (2) They have two legs in back and fore legs in front. (3) This makes a total of six legs, which certainly is an odd number of legs for a horse. (4) But the only number that is both odd and even is infinity. (5) Therefore, horses must have an infinite number of legs. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///