Skip to content

add empty() to PriorityConnPoolMap#18057

Merged
mattklein123 merged 4 commits intoenvoyproxy:mainfrom
lambdai:empty
Sep 10, 2021
Merged

add empty() to PriorityConnPoolMap#18057
mattklein123 merged 4 commits intoenvoyproxy:mainfrom
lambdai:empty

Conversation

@lambdai
Copy link
Contributor

@lambdai lambdai commented Sep 9, 2021

Commit Message:
Speed up a little bit since pool is very unlikely empty().

Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Copy link
Member

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

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

LGTM thanks, just a nit suggestion, do you want to add a comment in the function size() to say that it iterates over the map so that callers know to prefer empty()

@davinci26 davinci26 self-assigned this Sep 9, 2021
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@lambdai
Copy link
Contributor Author

lambdai commented Sep 9, 2021

LGTM thanks, just a nit suggestion, do you want to add a comment in the function size() to say that it iterates over the map so that callers know to prefer empty()

Linter should have reported it. After I add the empty(), my vscode starts to report it.
Also, the suggestion is applied to all stl container. Let's assume people think it as a stl container :)

davinci26
davinci26 previously approved these changes Sep 9, 2021
Copy link
Member

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

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

If the linter already reports it, then this is a way stronger signal than a docs comment

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Copy link
Member

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

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

LGTM, onto a second @envoyproxy/envoy-maintainers to review and merge

@mattklein123 mattklein123 merged commit 7d3057f into envoyproxy:main Sep 10, 2021
@lambdai lambdai deleted the empty branch September 10, 2021 23:20
/**
* @return true if the pools are empty.
*/
size_t empty() const;

Choose a reason for hiding this comment

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

should this return bool instead of size_t?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it definitely should. @lambdai can you post a followup to fix that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops. Sure

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.

5 participants