Skip to content

Refactoring lo.IntersectBy + adding loit.IntersectBy + adding doc#739

Merged
samber merged 6 commits intomasterfrom
feat/adding-it-intersectby
Nov 7, 2025
Merged

Refactoring lo.IntersectBy + adding loit.IntersectBy + adding doc#739
samber merged 6 commits intomasterfrom
feat/adding-it-intersectby

Conversation

@samber
Copy link
Owner

@samber samber commented Nov 6, 2025

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.04%. Comparing base (43ae3d7) to head (dac1d92).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
intersect.go 78.12% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
- Coverage   94.21%   94.04%   -0.17%     
==========================================
  Files          18       18              
  Lines        2817     2838      +21     
==========================================
+ Hits         2654     2669      +15     
- Misses        149      152       +3     
- Partials       14       17       +3     
Flag Coverage Δ
unittests 94.04% <78.12%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NathanBaulch
Copy link
Contributor

LGTM! My only complaint would be the duplicated code between Intersect and IntersectBy but we've got #737 to track that.

@samber
Copy link
Owner Author

samber commented Nov 7, 2025

Yes, same feeling for me.

@samber samber merged commit d99edab into master Nov 7, 2025
22 checks passed
@samber samber deleted the feat/adding-it-intersectby branch November 7, 2025 00:23
@d-enk
Copy link
Contributor

d-enk commented Nov 7, 2025

It looks much better

seen := make(map[T]bool, len(lists[len(lists)-1]))
for _, item := range lists[len(lists)-1] {
	seen[item] = true
}

for i := len(lists) - 2; i > 0; i-- {
...
}

result := make(Slice, 0, len(seen))
...
return result

than

for i := len(lists) - 1; i >= 0; i-- {
	if i == len(lists)-1 {
		for _, item := range lists[i] {
			seen[item] = true
		}
		continue
	}

	if i == 0 {
		result := make(Slice, 0, len(seen))
		...
		return result
	}
	
	...
}

return Slice{}

Or am I missing something?

@d-enk
Copy link
Contributor

d-enk commented Nov 7, 2025

@samber

Or at all

seen := make(map[T]bool, len(lists[0]))
for _, item := range lists[0] {
	seen[item] = true
}

for i := 1; i < len(lists) - 1; i++ {
...
}


for item := range lists[len(lists) - 1] {
...
}

return result

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.

3 participants