To: vim-dev@vim.org Subject: Patch 6.2.101 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.101 Problem: When using syntax folding, opening a file slows down a lot when it's size increases by only 20%. (Gary Johnson) Solution: The array with cached syntax states is leaking entries. After cleaning up the list obtain the current entry again. Files: src/syntax.c *** ../vim-6.2.100/src/syntax.c Sun Aug 10 14:52:30 2003 --- src/syntax.c Sat Sep 27 17:03:24 2003 *************** *** 1088,1094 **** { /* When shrinking the array, cleanup the existing stack. * Make sure that all valid entries fit in the new array. */ ! while (syn_buf->b_sst_len - syn_buf->b_sst_freecount + 2> len && syn_stack_cleanup()) ; if (len < syn_buf->b_sst_len - syn_buf->b_sst_freecount + 2) --- 1088,1094 ---- { /* When shrinking the array, cleanup the existing stack. * Make sure that all valid entries fit in the new array. */ ! while (syn_buf->b_sst_len - syn_buf->b_sst_freecount + 2 > len && syn_stack_cleanup()) ; if (len < syn_buf->b_sst_len - syn_buf->b_sst_freecount + 2) *************** *** 1322,1335 **** { if (sp != NULL) { ! /* find the entry just before this one */ ! for (p = syn_buf->b_sst_first; p != NULL; p = p->sst_next) ! if (p->sst_next == sp) ! break; ! if (p != NULL) ! p->sst_next = sp->sst_next; ! else syn_buf->b_sst_first = sp->sst_next; syn_stack_free_entry(syn_buf, sp); sp = NULL; } --- 1322,1339 ---- { if (sp != NULL) { ! /* find "sp" in the list and remove it */ ! if (syn_buf->b_sst_first == sp) ! /* it's the first entry */ syn_buf->b_sst_first = sp->sst_next; + else + { + /* find the entry just before this one to adjust sst_next */ + for (p = syn_buf->b_sst_first; p != NULL; p = p->sst_next) + if (p->sst_next == sp) + break; + p->sst_next = sp->sst_next; + } syn_stack_free_entry(syn_buf, sp); sp = NULL; } *************** *** 1341,1347 **** --- 1345,1355 ---- */ /* If no free items, cleanup the array first. */ if (syn_buf->b_sst_freecount == 0) + { (void)syn_stack_cleanup(); + /* "sp" may have been moved to the freelist now */ + sp = syn_stack_find_entry(current_lnum); + } /* Still no free items? Must be a strange problem... */ if (syn_buf->b_sst_freecount == 0) sp = NULL; *** ../vim-6.2.100/src/version.c Sat Sep 27 19:20:53 2003 --- src/version.c Sat Sep 27 19:24:52 2003 *************** *** 632,633 **** --- 638,641 ---- { /* Add new patch number below this line */ + /**/ + 101, /**/ -- Have you heard about the new Beowulf cluster? It's so fast, it executes an infinite loop in 6 seconds. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///