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

Optimization suggestion: Adding languages to hash table #170

Open
Peter015 opened this issue Jan 23, 2023 · 1 comment
Open

Optimization suggestion: Adding languages to hash table #170

Peter015 opened this issue Jan 23, 2023 · 1 comment

Comments

@Peter015
Copy link
Contributor

I have noticed that the function tree-sitter-langs--init-major-mode-alist iterates through a list of major mode-language pairs and adds them to the tree-sitter-major-mode-language-alist list. I believe that for improved performance, it would be better to use a hash table instead of iterating through the list. This would allow for constant-time lookups when a buffer is opened.

I have created an implementation that replaces the list with a hash table, and would gladly open a PR. It would also be possible to set the values of the hash table instead of iterating over the list of major-mode pairs.

Please let me know your thoughts on this proposal and if there is any interest.

Thank you!

@Peter015 Peter015 changed the title Optimization suggestion: Directly adding languages to hash table Optimization suggestion: Adding languages to hash table Jan 23, 2023
@Peter015
Copy link
Contributor Author

Peter015 commented Feb 1, 2023

If there are no suggestions/thoughts on this I will open a PR on Friday to move the discussion there

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

No branches or pull requests

1 participant