mirror of
https://github.com/tmux/tmux.git
synced 2025-03-24 06:48:48 +00:00
Do not go down the regex search path (which is expensive because we need
to convert the grid data into a string for regexec and reverse it to find the grid position) if the search string does not contain any regex special characters.
This commit is contained in:
parent
46092f2760
commit
b66d62d2d0
@ -2714,23 +2714,27 @@ window_copy_search(struct window_mode_entry *wme, int direction, int regex)
|
|||||||
struct screen *s = data->backing, ss;
|
struct screen *s = data->backing, ss;
|
||||||
struct screen_write_ctx ctx;
|
struct screen_write_ctx ctx;
|
||||||
struct grid *gd = s->grid;
|
struct grid *gd = s->grid;
|
||||||
|
const char *str = data->searchstr;
|
||||||
u_int fx, fy, endline;
|
u_int fx, fy, endline;
|
||||||
int wrapflag, cis, found;
|
int wrapflag, cis, found;
|
||||||
|
|
||||||
|
if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0')
|
||||||
|
regex = 0;
|
||||||
|
|
||||||
free(wp->searchstr);
|
free(wp->searchstr);
|
||||||
wp->searchstr = xstrdup(data->searchstr);
|
wp->searchstr = xstrdup(str);
|
||||||
wp->searchregex = regex;
|
wp->searchregex = regex;
|
||||||
|
|
||||||
fx = data->cx;
|
fx = data->cx;
|
||||||
fy = screen_hsize(data->backing) - data->oy + data->cy;
|
fy = screen_hsize(data->backing) - data->oy + data->cy;
|
||||||
|
|
||||||
screen_init(&ss, screen_write_strlen("%s", data->searchstr), 1, 0);
|
screen_init(&ss, screen_write_strlen("%s", str), 1, 0);
|
||||||
screen_write_start(&ctx, NULL, &ss);
|
screen_write_start(&ctx, NULL, &ss);
|
||||||
screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr);
|
screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", str);
|
||||||
screen_write_stop(&ctx);
|
screen_write_stop(&ctx);
|
||||||
|
|
||||||
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
||||||
cis = window_copy_is_lowercase(data->searchstr);
|
cis = window_copy_is_lowercase(str);
|
||||||
|
|
||||||
if (direction) {
|
if (direction) {
|
||||||
window_copy_move_right(s, &fx, &fy, wrapflag);
|
window_copy_move_right(s, &fx, &fy, wrapflag);
|
||||||
|
Loading…
Reference in New Issue
Block a user