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

Introduce IdentifierSet type for readability #6863

Open
tim-barry opened this issue Jan 9, 2025 · 0 comments
Open

Introduce IdentifierSet type for readability #6863

tim-barry opened this issue Jan 9, 2025 · 0 comments
Assignees
Labels
Improvement Protocol Team: Issues assigned to the Protocol Pillar.

Comments

@tim-barry
Copy link
Contributor

Problem Definition

The idiom of using a map[flow.Identifier]struct{} for a set or lookup table of Identifiers is somewhat commonly used around the codebase (117 occurrences). However, code manipulating and interacting with these is somewhat confusing and not obvious for people unfamiliar with this specific idiom of using a map to an empty struct.

Proposed Solution

By introducing an IdentifierSet type as an alias for map[flow.Identifier]struct{} alongside IdentifierList, and adding well-named methods to manipulate it, we can clarify and increase code readability. In fact, such a type already exists, but is only used in one file (node_blocklist_wrapper.go).

Definition of Done

Common operations on IdentifierSet used in multiple places should be factored into clear methods that improve readability, such as the already-existing (s IdentifierSet) Contains(id flow.Identifier) bool. No actual functionality should be changed.

@tim-barry tim-barry added Improvement Protocol Team: Issues assigned to the Protocol Pillar. labels Jan 9, 2025
@tim-barry tim-barry self-assigned this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Protocol Team: Issues assigned to the Protocol Pillar.
Projects
None yet
Development

No branches or pull requests

1 participant