Skip to content

chore: remove duplicates using the symmetric difference function - #14469

Merged
Emyrk merged 1 commit into
mainfrom
stevenmasley/slice_unique
Aug 29, 2024
Merged

Emyrk merged 1 commit into
mainfrom
stevenmasley/slice_unique

Conversation

@Emyrk

@Emyrk Emyrk commented Aug 28, 2024

Copy link
Copy Markdown
Member

Just limiting the diff of the giant organization sync PR.

The SymmetricDifferenceFunc used to include duplicates, which was incorrect.

Emyrk commented Aug 28, 2024

Copy link
Copy Markdown
Member Author

@Emyrk
Emyrk force-pushed the stevenmasley/organizations_query branch from d3aa5c4 to ccbe85e Compare August 28, 2024 14:41
@Emyrk
Emyrk force-pushed the stevenmasley/slice_unique branch from 5af8f78 to 1cc418c Compare August 28, 2024 14:41
@Emyrk
Emyrk force-pushed the stevenmasley/organizations_query branch from ccbe85e to bbcfc01 Compare August 28, 2024 14:44
@Emyrk
Emyrk force-pushed the stevenmasley/slice_unique branch from 1cc418c to 0a49b38 Compare August 28, 2024 14:44
@Emyrk Emyrk changed the title chore: implement unique function for slices chore: symmetric difference function to remove duplicates Aug 28, 2024
@Emyrk Emyrk changed the title chore: symmetric difference function to remove duplicates chore: remove duplicates using the symmetric difference function Aug 28, 2024
@Emyrk
Emyrk marked this pull request as ready for review August 28, 2024 14:46
@Emyrk
Emyrk force-pushed the stevenmasley/organizations_query branch from bbcfc01 to ba492b2 Compare August 28, 2024 16:22
@Emyrk
Emyrk force-pushed the stevenmasley/slice_unique branch 2 times, most recently from 369b2dc to 2d5e40d Compare August 28, 2024 16:29
@Emyrk
Emyrk requested a review from johnstcn August 28, 2024 16:38
@Emyrk
Emyrk changed the base branch from stevenmasley/organizations_query to graphite-base/14469 August 28, 2024 18:24
@Emyrk
Emyrk force-pushed the stevenmasley/slice_unique branch from 2d5e40d to 028476d Compare August 28, 2024 18:24
@Emyrk
Emyrk changed the base branch from graphite-base/14469 to main August 28, 2024 18:25
@Emyrk
Emyrk force-pushed the stevenmasley/slice_unique branch from 028476d to 6889229 Compare August 28, 2024 19:34
cpy := make([]T, 0, len(a))

for _, v := range a {
if ContainsCompare(cpy, v, equal) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the repeated iteration? Can you not just keep a map[T]struct{} around? Or are you trying to avoid the comparable constraint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am trying to avoid the comparable constraint because the RBAC uses RoleIdentifier structs which are not comparable 😢.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gotcha. We probably want to be careful that we don't use this for too large a slice then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea, atm the slices are in the order of 5-10 elements

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving to unblock.

@Emyrk
Emyrk merged commit 6dbfe6f into main Aug 29, 2024
@Emyrk
Emyrk deleted the stevenmasley/slice_unique branch August 29, 2024 02:06
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants