Closed piotrmurach closed 4 years ago
@DanielVartanov I decided to try and see how this may be solved. So far I get quite optimistic results. Thanks to caching selected items size there is even a small speed improvement over the baseline. Please review when you have a minute.
Hey! Sorry it took me too long to reply, crazy days.
This is amazing! :+1:
I figured out why my initial benchark was different -- I've been pre-selecting thousands of choices (to populate @selected
more) and then "clicking" one choice back and forth, apparently it did give the difference. BUT this solution beats everything in both benchmarks, I'm glad it's going to be merged
@piotrmurach sorry, can you please release the gem with this fix? I'm using tty-prompt
for a script of guided deployment where this fix is the difference between uptime and downtime.
@DanielVartanov Unfortunately, I cannot release the gem yet. I'm in the middle of adding :quiet
option and need to finish the newest pastel
version. This is a major release that I need to get 'right' as many things have been changed internally and many gems rely on (see changelog). Can you not patch the keyspace
method with the sort
solution for the time being? The release is nearly ready but I don't want to commit to a deadline. I will let you know once a new version gets released. Sorry, I know that's not the answer you expected but I hope you understand. I'm struggling to find time at the minute but will do my best to release soon.
@piotrmurach I see, no problem, I didn't realise it is a bigger deal than I initially thought :+1:
@DanielVartanov There are many changes, including new conversions that don't raise errors but provide info to the user. I hope a better user experience. I'm currently following a hand-drawn chart with all the tty gems on it and updating/fixing them one by one. The tty-prompt
and pastel
are my sole focus at the minute as they're used by a few other gems. So I expect to release them soonish provided I make good progress and find the time.
Adds
SelectedChoices
class to help keep the original choice order regardless of the selection order inmulti_select
prompt.