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

Limit the number of symbol completion candidates and make it faster #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tompng
Copy link
Member

@tompng tompng commented Oct 27, 2024

The number of symbol candidates can be huge.

Reduce calling symbol.inspect to make symbol search faster

symbols = 100000.times.map{rand(36**rand(5..25)).to_s(36).to_sym};
symbols.map{_1.inspect[1..]}.select{_1.start_with? 'ab'};
# processing time: 0.063232s
symbols.select{_1.start_with? 'ab'}.filter_map{a=_1.inspect[1..];a if a.start_with? 'ab'};
# processing time: 0.017167s

Limit the number of symbol completion candidates. Avoid calling large_symbol_array.sort and use min(n)+max(n).reverse. This will also improve performance of rendering completion dialog in Reline.

symbols.size
# => 100000
symbols.sort;
# processing time: 0.061497s
symbols.min(50)+symbols.max(50).reverse;
# processing time: 0.013646s

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