ichiban / prolog

The only reasonable scripting engine for Go.
MIT License
627 stars 32 forks source link

Optimize method for efficient key lookup in Dict implementation #341

Open coderabbitai[bot] opened 4 hours ago

coderabbitai[bot] commented 4 hours ago

As requested by @ccamel, this issue aims to improve the performance of the Value method in the Dict implementation within engine/dict.go. Currently, the Value method iterates over all key-value pairs, resulting in O(n) time complexity for key retrieval. The use of a list of terms for Dict representation was chosen to leverage Prolog’s pattern matching and unification capabilities through its compatibility with compound terms. However, there's room for enhancement in this approach to boost performance.

PR URL: https://github.com/axone-protocol/prolog/pull/17

Comment URL: https://github.com/axone-protocol/prolog/pull/17#discussion_r1843652844

ccamel commented 3 hours ago

@ichiban Oops, looks like this issue was accidentally created by Coderabbit on this repo instead of mine (which is a fork). Not sure why that happened—guess the bots are starting to make their own decisions now! 😅 Feel free to close the issue. Sorry for the hassle! 🙏