Hi! Thanks for this neat library, I appreciate your work.
If you're open to contributions, this PR changes the implementation of predictive_search to perform an iterative preorder traversal of the trie, instead of recursive calls. In benchmarks on my machine that's about a 45% reduction in latency. Tests are passing. This is relevant to https://github.com/laysakura/trie-rs/issues/10 .
Relatedly: would you be open to a future PR that returns suggestions as an Iterator? The idea being you can do trie.predictive_suggestions("foo").take(k) to grab K suggestions rather than all of them (and potentially skip some of the work!).
Hi! Thanks for this neat library, I appreciate your work.
If you're open to contributions, this PR changes the implementation of
predictive_search
to perform an iterative preorder traversal of the trie, instead of recursive calls. In benchmarks on my machine that's about a45%
reduction in latency. Tests are passing. This is relevant to https://github.com/laysakura/trie-rs/issues/10 .Relatedly: would you be open to a future PR that returns suggestions as an
Iterator
? The idea being you can dotrie.predictive_suggestions("foo").take(k)
to grabK
suggestions rather than all of them (and potentially skip some of the work!).