home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.1145 < prev    next >
Encoding:
Internet Message Format  |  2013-06-06  |  3.9 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.1145
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.1145
  11. Problem:    New regexp engine: addstate() is called very often.
  12. Solution:   Optimize adding the start state.
  13. Files:        src/regexp_nfa.c
  14.  
  15.  
  16. *** ../vim-7.3.1144/src/regexp_nfa.c    2013-06-07 17:31:25.000000000 +0200
  17. --- src/regexp_nfa.c    2013-06-07 22:03:12.000000000 +0200
  18. ***************
  19. *** 4332,4340 ****
  20.       nfa_list_T    *nextlist;
  21.       int        *listids = NULL;
  22.       nfa_state_T *add_state;
  23. !     int         add_count;
  24. !     int         add_off;
  25.       garray_T    pimlist;
  26.   #ifdef NFA_REGEXP_DEBUG_LOG
  27.       FILE    *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
  28.   
  29. --- 4332,4341 ----
  30.       nfa_list_T    *nextlist;
  31.       int        *listids = NULL;
  32.       nfa_state_T *add_state;
  33. !     int        add_count;
  34. !     int        add_off;
  35.       garray_T    pimlist;
  36. +     int        toplevel = start->c == NFA_MOPEN;
  37.   #ifdef NFA_REGEXP_DEBUG_LOG
  38.       FILE    *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
  39.   
  40. ***************
  41. *** 4378,4387 ****
  42.       nextlist = &list[1];
  43.       nextlist->n = 0;
  44.   #ifdef ENABLE_LOG
  45. !     fprintf(log_fd, "(---) STARTSTATE\n");
  46.   #endif
  47.       thislist->id = nfa_listid + 1;
  48. !     addstate(thislist, start, m, 0);
  49.   
  50.   #define    ADD_STATE_IF_MATCH(state)            \
  51.       if (result) {                    \
  52. --- 4379,4404 ----
  53.       nextlist = &list[1];
  54.       nextlist->n = 0;
  55.   #ifdef ENABLE_LOG
  56. !     fprintf(log_fd, "(---) STARTSTATE first\n");
  57.   #endif
  58.       thislist->id = nfa_listid + 1;
  59. !     /* Inline optimized code for addstate(thislist, start, m, 0) if we know
  60. !      * it's the first MOPEN. */
  61. !     if (toplevel)
  62. !     {
  63. !     if (REG_MULTI)
  64. !     {
  65. !         m->norm.list.multi[0].start.lnum = reglnum;
  66. !         m->norm.list.multi[0].start.col = (colnr_T)(reginput - regline);
  67. !     }
  68. !     else
  69. !         m->norm.list.line[0].start = reginput;
  70. !     m->norm.in_use = 1;
  71. !     addstate(thislist, start->out, m, 0);
  72. !     }
  73. !     else
  74. !     addstate(thislist, start, m, 0);
  75.   
  76.   #define    ADD_STATE_IF_MATCH(state)            \
  77.       if (result) {                    \
  78. ***************
  79. *** 5382,5388 ****
  80.        * Unless "nfa_endp" is not NULL, then we match the end position.
  81.        * Also don't start a match past the first line. */
  82.       if (nfa_match == FALSE
  83. !         && ((start->c == NFA_MOPEN
  84.               && reglnum == 0
  85.               && clen != 0
  86.               && (ireg_maxcol == 0
  87. --- 5399,5405 ----
  88.        * Unless "nfa_endp" is not NULL, then we match the end position.
  89.        * Also don't start a match past the first line. */
  90.       if (nfa_match == FALSE
  91. !         && ((toplevel
  92.               && reglnum == 0
  93.               && clen != 0
  94.               && (ireg_maxcol == 0
  95. ***************
  96. *** 5398,5404 ****
  97.   #ifdef ENABLE_LOG
  98.           fprintf(log_fd, "(---) STARTSTATE\n");
  99.   #endif
  100. !         addstate(nextlist, start, m, clen);
  101.       }
  102.   
  103.   #ifdef ENABLE_LOG
  104. --- 5415,5433 ----
  105.   #ifdef ENABLE_LOG
  106.           fprintf(log_fd, "(---) STARTSTATE\n");
  107.   #endif
  108. !         /* Inline optimized code for addstate() if we know the state is
  109. !          * the first MOPEN. */
  110. !         if (toplevel)
  111. !         {
  112. !         if (REG_MULTI)
  113. !             m->norm.list.multi[0].start.col =
  114. !                      (colnr_T)(reginput - regline) + clen;
  115. !         else
  116. !             m->norm.list.line[0].start = reginput + clen;
  117. !         addstate(nextlist, start->out, m, clen);
  118. !         }
  119. !         else
  120. !         addstate(nextlist, start, m, clen);
  121.       }
  122.   
  123.   #ifdef ENABLE_LOG
  124. *** ../vim-7.3.1144/src/version.c    2013-06-07 20:17:06.000000000 +0200
  125. --- src/version.c    2013-06-07 22:37:03.000000000 +0200
  126. ***************
  127. *** 730,731 ****
  128. --- 730,733 ----
  129.   {   /* Add new patch number below this line */
  130. + /**/
  131. +     1145,
  132.   /**/
  133.  
  134. -- 
  135. hundred-and-one symptoms of being an internet addict:
  136. 104. When people ask about the Presidential Election you ask "Which country?"
  137.  
  138.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  139. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  140. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  141.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  142.