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

Rework registry to seach with O(1) #188

Closed
DifferentialOrange opened this issue Feb 9, 2021 · 1 comment · Fixed by #244
Closed

Rework registry to seach with O(1) #188

DifferentialOrange opened this issue Feb 9, 2021 · 1 comment · Fixed by #244
Labels
refactoring Code refactoring

Comments

@DifferentialOrange
Copy link
Member

Registry collector search сomputational complexity is O(N) where N is quantity of collectors

for _, c in ipairs(self.collectors) do

But Lua has hash tables, and with them we can search with O(1) at most times (and it's not like hash collision will happen often with standard number of collectors). All we need is to use kind+name key instead of plain array, i.e.

{ [ kind1 .. name1] = collector1, ... }

instead of

{ [1] = collector1 }

since kind+name must be unique. Moreover, it is more common to search for user collectors, but in registry array they always will be placed after default collectors, so it will be .

@DifferentialOrange DifferentialOrange added question Further information is requested refactoring Code refactoring labels Feb 9, 2021
@yngvar-antonsson yngvar-antonsson removed the question Further information is requested label Mar 1, 2021
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code refactoring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants