emacs-tree-sitter/tree-sitter-langs

Optimization suggestion: Adding languages to hash table

Peter015 opened this issue · 1 comments

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!

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