Skip to content

Commit 912e787

Browse files
committed
Tentative performance fix
1 parent 423c87d commit 912e787

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pick.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,19 @@ selected_choice(void)
354354
length = choices.length;
355355
if (doread) {
356356
if (get_choices(STDIN_FILENO)) {
357-
if (query_length > 0)
357+
if (query_length > 0) {
358358
dofilter = 1;
359+
query_grew = 1;
360+
for (i = length; i < choices.length; i++) {
361+
struct choice *new, *old, tmp;
362+
new = choices.v + i;
363+
old = choices.v + choices_count + (i - length);
364+
tmp = *new;
365+
*new = *old;
366+
*old = tmp;
367+
}
368+
choices_count += choices.length - length;
369+
}
359370
} else {
360371
/*
361372
* if xpoll uses kqueue, close the fd in order

0 commit comments

Comments
 (0)