Mercurial > vim
comparison src/quickfix.c @ 9201:692e156c7023 v7.4.1884
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 3 19:05:49 2016 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 03 Jun 2016 19:15:05 +0200 |
parents | 847a709d04c1 |
children | 674f9e3ccd1a |
comparison
equal
deleted
inserted
replaced
9200:5f97922c67d7 | 9201:692e156c7023 |
---|---|
1176 qfline_T **lastp; /* pointer to qf_last or NULL */ | 1176 qfline_T **lastp; /* pointer to qf_last or NULL */ |
1177 | 1177 |
1178 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) | 1178 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) |
1179 return FAIL; | 1179 return FAIL; |
1180 if (bufnum != 0) | 1180 if (bufnum != 0) |
1181 { | |
1182 buf_T *buf = buflist_findnr(bufnum); | |
1183 | |
1181 qfp->qf_fnum = bufnum; | 1184 qfp->qf_fnum = bufnum; |
1185 if (buf != NULL) | |
1186 buf->b_has_qf_entry = TRUE; | |
1187 } | |
1182 else | 1188 else |
1183 qfp->qf_fnum = qf_get_fnum(dir, fname); | 1189 qfp->qf_fnum = qf_get_fnum(dir, fname); |
1184 if ((qfp->qf_text = vim_strsave(mesg)) == NULL) | 1190 if ((qfp->qf_text = vim_strsave(mesg)) == NULL) |
1185 { | 1191 { |
1186 vim_free(qfp); | 1192 vim_free(qfp); |
1376 | 1382 |
1377 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */ | 1383 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */ |
1378 } | 1384 } |
1379 | 1385 |
1380 /* | 1386 /* |
1381 * get buffer number for file "dir.name" | 1387 * Get buffer number for file "dir.name". |
1388 * Also sets the b_has_qf_entry flag. | |
1382 */ | 1389 */ |
1383 static int | 1390 static int |
1384 qf_get_fnum(char_u *directory, char_u *fname) | 1391 qf_get_fnum(char_u *directory, char_u *fname) |
1385 { | 1392 { |
1393 char_u *ptr; | |
1394 buf_T *buf; | |
1395 | |
1386 if (fname == NULL || *fname == NUL) /* no file name */ | 1396 if (fname == NULL || *fname == NUL) /* no file name */ |
1387 return 0; | 1397 return 0; |
1388 { | |
1389 char_u *ptr; | |
1390 int fnum; | |
1391 | 1398 |
1392 #ifdef VMS | 1399 #ifdef VMS |
1393 vms_remove_version(fname); | 1400 vms_remove_version(fname); |
1394 #endif | 1401 #endif |
1395 #ifdef BACKSLASH_IN_FILENAME | 1402 #ifdef BACKSLASH_IN_FILENAME |
1396 if (directory != NULL) | 1403 if (directory != NULL) |
1397 slash_adjust(directory); | 1404 slash_adjust(directory); |
1398 slash_adjust(fname); | 1405 slash_adjust(fname); |
1399 #endif | 1406 #endif |
1400 if (directory != NULL && !vim_isAbsName(fname) | 1407 if (directory != NULL && !vim_isAbsName(fname) |
1401 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) | 1408 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) |
1402 { | 1409 { |
1403 /* | 1410 /* |
1404 * Here we check if the file really exists. | 1411 * Here we check if the file really exists. |
1405 * This should normally be true, but if make works without | 1412 * This should normally be true, but if make works without |
1406 * "leaving directory"-messages we might have missed a | 1413 * "leaving directory"-messages we might have missed a |
1407 * directory change. | 1414 * directory change. |
1408 */ | 1415 */ |
1409 if (mch_getperm(ptr) < 0) | 1416 if (mch_getperm(ptr) < 0) |
1410 { | 1417 { |
1411 vim_free(ptr); | |
1412 directory = qf_guess_filepath(fname); | |
1413 if (directory) | |
1414 ptr = concat_fnames(directory, fname, TRUE); | |
1415 else | |
1416 ptr = vim_strsave(fname); | |
1417 } | |
1418 /* Use concatenated directory name and file name */ | |
1419 fnum = buflist_add(ptr, 0); | |
1420 vim_free(ptr); | 1418 vim_free(ptr); |
1421 return fnum; | 1419 directory = qf_guess_filepath(fname); |
1422 } | 1420 if (directory) |
1423 return buflist_add(fname, 0); | 1421 ptr = concat_fnames(directory, fname, TRUE); |
1424 } | 1422 else |
1423 ptr = vim_strsave(fname); | |
1424 } | |
1425 /* Use concatenated directory name and file name */ | |
1426 buf = buflist_new(ptr, NULL, (linenr_T)0, 0); | |
1427 vim_free(ptr); | |
1428 } | |
1429 else | |
1430 buf = buflist_new(fname, NULL, (linenr_T)0, 0); | |
1431 if (buf == NULL) | |
1432 return 0; | |
1433 buf->b_has_qf_entry = TRUE; | |
1434 return buf->b_fnum; | |
1425 } | 1435 } |
1426 | 1436 |
1427 /* | 1437 /* |
1428 * push dirbuf onto the directory stack and return pointer to actual dir or | 1438 * push dirbuf onto the directory stack and return pointer to actual dir or |
1429 * NULL on error | 1439 * NULL on error |
2412 { | 2422 { |
2413 int i; | 2423 int i; |
2414 qfline_T *qfp; | 2424 qfline_T *qfp; |
2415 int idx; | 2425 int idx; |
2416 qf_info_T *qi = &ql_info; | 2426 qf_info_T *qi = &ql_info; |
2417 | 2427 int found_one = FALSE; |
2428 | |
2429 if (!curbuf->b_has_qf_entry) | |
2430 return; | |
2418 if (wp != NULL) | 2431 if (wp != NULL) |
2419 { | 2432 { |
2420 if (wp->w_llist == NULL) | 2433 if (wp->w_llist == NULL) |
2421 return; | 2434 return; |
2422 qi = wp->w_llist; | 2435 qi = wp->w_llist; |
2427 for (i = 0, qfp = qi->qf_lists[idx].qf_start; | 2440 for (i = 0, qfp = qi->qf_lists[idx].qf_start; |
2428 i < qi->qf_lists[idx].qf_count && qfp != NULL; | 2441 i < qi->qf_lists[idx].qf_count && qfp != NULL; |
2429 ++i, qfp = qfp->qf_next) | 2442 ++i, qfp = qfp->qf_next) |
2430 if (qfp->qf_fnum == curbuf->b_fnum) | 2443 if (qfp->qf_fnum == curbuf->b_fnum) |
2431 { | 2444 { |
2445 found_one = TRUE; | |
2432 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) | 2446 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) |
2433 { | 2447 { |
2434 if (amount == MAXLNUM) | 2448 if (amount == MAXLNUM) |
2435 qfp->qf_cleared = TRUE; | 2449 qfp->qf_cleared = TRUE; |
2436 else | 2450 else |
2437 qfp->qf_lnum += amount; | 2451 qfp->qf_lnum += amount; |
2438 } | 2452 } |
2439 else if (amount_after && qfp->qf_lnum > line2) | 2453 else if (amount_after && qfp->qf_lnum > line2) |
2440 qfp->qf_lnum += amount_after; | 2454 qfp->qf_lnum += amount_after; |
2441 } | 2455 } |
2456 | |
2457 if (!found_one) | |
2458 curbuf->b_has_qf_entry = FALSE; | |
2442 } | 2459 } |
2443 | 2460 |
2444 /* | 2461 /* |
2445 * Make a nice message out of the error character and the error number: | 2462 * Make a nice message out of the error character and the error number: |
2446 * char number message | 2463 * char number message |