Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-hanging optimization #251

Merged
merged 3 commits into from
Sep 25, 2017
Merged

Low-hanging optimization #251

merged 3 commits into from
Sep 25, 2017

Conversation

mptre
Copy link
Owner

@mptre mptre commented Sep 23, 2017

If the user didn't add more characters to the query all choices have to
be reconsidered as potential matches. In the opposite scenario, there's
no point in reconsidered all choices again since the ones that didn't
match the previous query will clearly not match the current one due to
the fact that previous query is a left-most substring of the current
one.

Testing would be much appreciated. On large inputs, pick should feel
snappier by now.

@ghost
Copy link

ghost commented Sep 23, 2017

gcc (nb2 20150115) 4.8.5 on NetBSD 7.1 shows:

pick.c: In function 'main':
pick.c:554:2: error: 'choices_count' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  for (i = 0; i < nchoices; i++) {
  ^
pick.c:300:11: note: 'choices_count' was declared here
  size_t   choices_count, cursor_position, i, j, length, xscroll;

... no such errors on Debian ... nevertheless:

diff --git a/pick.c b/pick.c
index 8d42f50..e5f3723 100644
--- a/pick.c
+++ b/pick.c
@@ -303,6 +303,7 @@ selected_choice(void)
        int              dofilter = 1;
        int              query_grew = 0;
 
+       choices_count = choices.length;
        cursor_position = query_length;
 
        for (;;) {

@mptre
Copy link
Owner Author

mptre commented Sep 24, 2017

Thanks for testing @DBOTW. Could your try the latest commit on this
branch?

@ghost
Copy link

ghost commented Sep 24, 2017

@mptre: tested & works (GCC 2.95 also complained about this) ...

If the user didn't add more characters to the query all choices have to
be reconsidered as potential matches. In the opposite scenario, there's
no point in reconsidered all choices again since the ones that didn't
match the previous query will clearly not match the current one due to
the fact that previous query is a left-most substring of the current
one.
In order to silence GCC 2.95 and 4.8.5 on NetBSD. Sure looks like a
false-positive too me. Reported by Jenz Guenther in PR #251.
@mptre
Copy link
Owner Author

mptre commented Sep 25, 2017

Thanks, merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant