To: vim_dev@googlegroups.com Subject: Patch 7.4.1884 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1884 Problem: Updating marks in a quickfix list is very slow when the list is long. Solution: Only update marks if the buffer has a quickfix entry. Files: src/structs.h, src/quickfix.c *** ../vim-7.4.1883/src/structs.h 2016-05-29 16:44:22.157304121 +0200 --- src/structs.h 2016-06-03 18:32:27.931272399 +0200 *************** *** 1865,1873 **** #ifdef FEAT_MBYTE int b_p_bomb; /* 'bomb' */ #endif ! #if defined(FEAT_QUICKFIX) char_u *b_p_bh; /* 'bufhidden' */ char_u *b_p_bt; /* 'buftype' */ #endif int b_p_bl; /* 'buflisted' */ #ifdef FEAT_CINDENT --- 1865,1874 ---- #ifdef FEAT_MBYTE int b_p_bomb; /* 'bomb' */ #endif ! #ifdef FEAT_QUICKFIX char_u *b_p_bh; /* 'bufhidden' */ char_u *b_p_bt; /* 'buftype' */ + int b_has_qf_entry; #endif int b_p_bl; /* 'buflisted' */ #ifdef FEAT_CINDENT *************** *** 2465,2471 **** int w_wrow, w_wcol; /* cursor position in window */ linenr_T w_botline; /* number of the line below the bottom of ! the screen */ int w_empty_rows; /* number of ~ rows in window */ #ifdef FEAT_DIFF int w_filler_rows; /* number of filler rows at the end of the --- 2466,2472 ---- int w_wrow, w_wcol; /* cursor position in window */ linenr_T w_botline; /* number of the line below the bottom of ! the window */ int w_empty_rows; /* number of ~ rows in window */ #ifdef FEAT_DIFF int w_filler_rows; /* number of filler rows at the end of the *** ../vim-7.4.1883/src/quickfix.c 2016-06-02 22:18:44.040274149 +0200 --- src/quickfix.c 2016-06-03 19:02:40.395247467 +0200 *************** *** 1178,1184 **** --- 1178,1190 ---- if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) return FAIL; if (bufnum != 0) + { + buf_T *buf = buflist_findnr(bufnum); + qfp->qf_fnum = bufnum; + if (buf != NULL) + buf->b_has_qf_entry = TRUE; + } else qfp->qf_fnum = qf_get_fnum(dir, fname); if ((qfp->qf_text = vim_strsave(mesg)) == NULL) *************** *** 1378,1427 **** } /* ! * get buffer number for file "dir.name" */ static int qf_get_fnum(char_u *directory, char_u *fname) { if (fname == NULL || *fname == NUL) /* no file name */ return 0; - { - char_u *ptr; - int fnum; #ifdef VMS ! vms_remove_version(fname); #endif #ifdef BACKSLASH_IN_FILENAME ! if (directory != NULL) ! slash_adjust(directory); ! slash_adjust(fname); #endif ! if (directory != NULL && !vim_isAbsName(fname) ! && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) { - /* - * Here we check if the file really exists. - * This should normally be true, but if make works without - * "leaving directory"-messages we might have missed a - * directory change. - */ - if (mch_getperm(ptr) < 0) - { - vim_free(ptr); - directory = qf_guess_filepath(fname); - if (directory) - ptr = concat_fnames(directory, fname, TRUE); - else - ptr = vim_strsave(fname); - } - /* Use concatenated directory name and file name */ - fnum = buflist_add(ptr, 0); vim_free(ptr); ! return fnum; } ! return buflist_add(fname, 0); } } /* --- 1384,1437 ---- } /* ! * Get buffer number for file "dir.name". ! * Also sets the b_has_qf_entry flag. */ static int qf_get_fnum(char_u *directory, char_u *fname) { + char_u *ptr; + buf_T *buf; + if (fname == NULL || *fname == NUL) /* no file name */ return 0; #ifdef VMS ! vms_remove_version(fname); #endif #ifdef BACKSLASH_IN_FILENAME ! if (directory != NULL) ! slash_adjust(directory); ! slash_adjust(fname); #endif ! if (directory != NULL && !vim_isAbsName(fname) ! && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) ! { ! /* ! * Here we check if the file really exists. ! * This should normally be true, but if make works without ! * "leaving directory"-messages we might have missed a ! * directory change. ! */ ! if (mch_getperm(ptr) < 0) { vim_free(ptr); ! directory = qf_guess_filepath(fname); ! if (directory) ! ptr = concat_fnames(directory, fname, TRUE); ! else ! ptr = vim_strsave(fname); } ! /* Use concatenated directory name and file name */ ! buf = buflist_new(ptr, NULL, (linenr_T)0, 0); ! vim_free(ptr); } + else + buf = buflist_new(fname, NULL, (linenr_T)0, 0); + if (buf == NULL) + return 0; + buf->b_has_qf_entry = TRUE; + return buf->b_fnum; } /* *************** *** 2414,2420 **** --- 2424,2433 ---- qfline_T *qfp; int idx; qf_info_T *qi = &ql_info; + int found_one = FALSE; + if (!curbuf->b_has_qf_entry) + return; if (wp != NULL) { if (wp->w_llist == NULL) *************** *** 2429,2434 **** --- 2442,2448 ---- ++i, qfp = qfp->qf_next) if (qfp->qf_fnum == curbuf->b_fnum) { + found_one = TRUE; if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) { if (amount == MAXLNUM) *************** *** 2439,2444 **** --- 2453,2461 ---- else if (amount_after && qfp->qf_lnum > line2) qfp->qf_lnum += amount_after; } + + if (!found_one) + curbuf->b_has_qf_entry = FALSE; } /* *** ../vim-7.4.1883/src/version.c 2016-06-02 22:27:04.260267269 +0200 --- src/version.c 2016-06-03 18:33:12.467271786 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 1884, /**/ -- The 50-50-90 rule: Anytime you have a 50-50 chance of getting something right, there's a 90% probability you'll get it wrong. /// 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 ///