diff --git a/src/quickfix.c b/src/quickfix.c index a719e4f..3a9adaa 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -52,6 +52,7 @@ struct qfline_S typedef struct qf_list_S { qfline_T *qf_start; /* pointer to the first error */ + qfline_T *qf_last; /* pointer to the last error */ qfline_T *qf_ptr; /* pointer to the current error */ int qf_count; /* number of errors (0 means no error list) */ int qf_index; /* current index in the error list */ @@ -304,10 +305,10 @@ qf_init_ext( /* make place for a new list */ qf_new_list(qi, qf_title); else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) + { /* Adding to existing list, find last entry. */ - for (qfprev = qi->qf_lists[qi->qf_curlist].qf_start; - qfprev->qf_next != qfprev; qfprev = qfprev->qf_next) - ; + qfprev = qi->qf_lists[qi->qf_curlist].qf_last; + } /* * Each part of the format string is copied and modified from errorformat to @@ -1209,6 +1210,7 @@ qf_add_entry( (*prevp)->qf_next = qfp; } qfp->qf_next = qfp; /* last element points to itself */ + qi->qf_lists[qi->qf_curlist].qf_last = qfp; qfp->qf_cleared = FALSE; *prevp = qfp; ++qi->qf_lists[qi->qf_curlist].qf_count; @@ -1308,6 +1310,7 @@ copy_loclist(win_T *from, win_T *to) to_qfl->qf_count = 0; to_qfl->qf_index = 0; to_qfl->qf_start = NULL; + to_qfl->qf_last = NULL; to_qfl->qf_ptr = NULL; if (from_qfl->qf_title != NULL) to_qfl->qf_title = vim_strsave(from_qfl->qf_title); @@ -2381,6 +2384,7 @@ qf_free(qf_info_T *qi, int idx) vim_free(qi->qf_lists[idx].qf_title); qi->qf_lists[idx].qf_title = NULL; qi->qf_lists[idx].qf_index = 0; + qi->qf_lists[idx].qf_last = NULL; } /* @@ -3618,9 +3622,7 @@ ex_vimgrep(exarg_T *eap) qf_new_list(qi, title != NULL ? title : *eap->cmdlinep); else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) /* Adding to existing list, find last entry. */ - for (prevp = qi->qf_lists[qi->qf_curlist].qf_start; - prevp->qf_next != prevp; prevp = prevp->qf_next) - ; + prevp = qi->qf_lists[qi->qf_curlist].qf_last; /* parse the list of arguments */ if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) @@ -4210,9 +4212,7 @@ set_errorlist( qf_new_list(qi, title); else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0) /* Adding to existing list, find last entry. */ - for (prevp = qi->qf_lists[qi->qf_curlist].qf_start; - prevp->qf_next != prevp; prevp = prevp->qf_next) - ; + prevp = qi->qf_lists[qi->qf_curlist].qf_last; else if (action == 'r') { qf_free(qi, qi->qf_curlist);