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

Change MapSize() complexity to O(1) even if it's a hash map #197

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

vpodzime
Copy link
Contributor

@vpodzime vpodzime commented Nov 3, 2023

No need to iterate, a HashMap has the load field which contains the number of elements in the map.

Ticket: CFE-3043
Changelog: Complexity of MapSize() is now O(1) in all cases

No need to iterate, a HashMap has the `load` field which contains
the number of elements in the map.

Ticket: CFE-3043
Changelog: Complexity of MapSize() is now O(1) in all cases
@vpodzime vpodzime requested a review from larsewi November 3, 2023 11:18
@mender-test-bot
Copy link

There was an error running your pipeline, see logs for details.

Copy link
Contributor

@olehermanse olehermanse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next step, make it a static inline function?

@vpodzime
Copy link
Contributor Author

vpodzime commented Nov 3, 2023

Next step, make it a static inline function?

It's definitely an option. Although, I think the stuff in map.h (where it would have to be defined) should use as least of the _priv.h headers as possible. In fact, we should try to remove their #includes from map.h.

@vpodzime vpodzime merged commit 469add7 into NorthernTechHQ:master Nov 6, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants