#endif
buf_T *buf;
- for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+ /* Start at the last buffer, expect to find a match sooner. */
+ for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname
#ifdef UNIX
, stp
return -1;
}
- for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+ for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
if (buf->b_p_bl == find_listed
#ifdef FEAT_DIFF
&& (!diffmode || diff_mode_buf(buf))
if (nr == 0)
nr = curwin->w_alt_fnum;
- for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+ /* Assume newer buffers are used more often, start from the end. */
+ for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
if (buf->b_fnum == nr)
return buf;
return NULL;
aucmd_restbuf(&aco);
if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe))
wipe_buffer(newbuf_to_wipe, FALSE);
+
+ /* Add back the "dummy" flag, otherwise buflist_findname_stat() won't
+ * skip it. */
+ newbuf->b_flags |= BF_DUMMY;
}
/*