From aa0805b99fee5d55eaad0ebecc403c76a444eb81 Mon Sep 17 00:00:00 2001 From: Karsten Hopp Date: Jun 13 2013 22:28:30 +0000 Subject: - patchlevel 1145 --- diff --git a/7.3.1145 b/7.3.1145 new file mode 100644 index 0000000..bab42f3 --- /dev/null +++ b/7.3.1145 @@ -0,0 +1,142 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.1145 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.1145 +Problem: New regexp engine: addstate() is called very often. +Solution: Optimize adding the start state. +Files: src/regexp_nfa.c + + +*** ../vim-7.3.1144/src/regexp_nfa.c 2013-06-07 17:31:25.000000000 +0200 +--- src/regexp_nfa.c 2013-06-07 22:03:12.000000000 +0200 +*************** +*** 4332,4340 **** + nfa_list_T *nextlist; + int *listids = NULL; + nfa_state_T *add_state; +! int add_count; +! int add_off; + garray_T pimlist; + #ifdef NFA_REGEXP_DEBUG_LOG + FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); + +--- 4332,4341 ---- + nfa_list_T *nextlist; + int *listids = NULL; + nfa_state_T *add_state; +! int add_count; +! int add_off; + garray_T pimlist; ++ int toplevel = start->c == NFA_MOPEN; + #ifdef NFA_REGEXP_DEBUG_LOG + FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); + +*************** +*** 4378,4387 **** + nextlist = &list[1]; + nextlist->n = 0; + #ifdef ENABLE_LOG +! fprintf(log_fd, "(---) STARTSTATE\n"); + #endif + thislist->id = nfa_listid + 1; +! addstate(thislist, start, m, 0); + + #define ADD_STATE_IF_MATCH(state) \ + if (result) { \ +--- 4379,4404 ---- + nextlist = &list[1]; + nextlist->n = 0; + #ifdef ENABLE_LOG +! fprintf(log_fd, "(---) STARTSTATE first\n"); + #endif + thislist->id = nfa_listid + 1; +! +! /* Inline optimized code for addstate(thislist, start, m, 0) if we know +! * it's the first MOPEN. */ +! if (toplevel) +! { +! if (REG_MULTI) +! { +! m->norm.list.multi[0].start.lnum = reglnum; +! m->norm.list.multi[0].start.col = (colnr_T)(reginput - regline); +! } +! else +! m->norm.list.line[0].start = reginput; +! m->norm.in_use = 1; +! addstate(thislist, start->out, m, 0); +! } +! else +! addstate(thislist, start, m, 0); + + #define ADD_STATE_IF_MATCH(state) \ + if (result) { \ +*************** +*** 5382,5388 **** + * Unless "nfa_endp" is not NULL, then we match the end position. + * Also don't start a match past the first line. */ + if (nfa_match == FALSE +! && ((start->c == NFA_MOPEN + && reglnum == 0 + && clen != 0 + && (ireg_maxcol == 0 +--- 5399,5405 ---- + * Unless "nfa_endp" is not NULL, then we match the end position. + * Also don't start a match past the first line. */ + if (nfa_match == FALSE +! && ((toplevel + && reglnum == 0 + && clen != 0 + && (ireg_maxcol == 0 +*************** +*** 5398,5404 **** + #ifdef ENABLE_LOG + fprintf(log_fd, "(---) STARTSTATE\n"); + #endif +! addstate(nextlist, start, m, clen); + } + + #ifdef ENABLE_LOG +--- 5415,5433 ---- + #ifdef ENABLE_LOG + fprintf(log_fd, "(---) STARTSTATE\n"); + #endif +! /* Inline optimized code for addstate() if we know the state is +! * the first MOPEN. */ +! if (toplevel) +! { +! if (REG_MULTI) +! m->norm.list.multi[0].start.col = +! (colnr_T)(reginput - regline) + clen; +! else +! m->norm.list.line[0].start = reginput + clen; +! addstate(nextlist, start->out, m, clen); +! } +! else +! addstate(nextlist, start, m, clen); + } + + #ifdef ENABLE_LOG +*** ../vim-7.3.1144/src/version.c 2013-06-07 20:17:06.000000000 +0200 +--- src/version.c 2013-06-07 22:37:03.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 1145, + /**/ + +-- +hundred-and-one symptoms of being an internet addict: +104. When people ask about the Presidential Election you ask "Which country?" + + /// 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 ///