You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: