server icon indicating copy to clipboard operation
server copied to clipboard

🔨 Make zone:queryEntitiesByName() fast

Open zach2good opened this issue 3 years ago • 0 comments

  • [x] I have paid attention to this example and will edit again if need be to not break the formatting, or I will be ignored
  • [x] I have searched existing issues to see if the issue has already been opened, and I have checked the commit log to see if the issue has been resolved since my server was last updated
  • [x] I have read and understood the Contributing Guide

Describe the feature

We're currently getting a lot of use and safety out of zone:queryEntitiesByName() but the current implementation is $O(n)$. We need to bring this down to at worst $O(log n)$, but more likely $O(1)$.

We'll probably want to populate a std::unordered_map<std::string, std::vector<CLuaEntity>> at startup, and use that for our lookups.

This however won't work for dynamic entities, so we'd also need a way to force the linear search by name.

zach2good avatar Jul 19 '22 12:07 zach2good