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

Equal() panics when called with bitsets with different set lengths #116

Closed
omerfirmak opened this issue Jan 24, 2023 · 1 comment · Fixed by #117
Closed

Equal() panics when called with bitsets with different set lengths #116

omerfirmak opened this issue Jan 24, 2023 · 1 comment · Fixed by #117

Comments

@omerfirmak
Copy link
Contributor

omerfirmak commented Jan 24, 2023

bitset/bitset.go

Lines 603 to 615 in 312c8c2

if b.length != c.length {
return false
}
if b.length == 0 { // if they have both length == 0, then could have nil set
return true
}
// testing for equality shoud not transform the bitset (no call to safeSet)
for p, v := range b.set {
if c.set[p] != v {
return false
}
}

even tho b.length == c.length, len(b.set) and len(c.set) could be different.

Equal should check if wordsNeeded(b.length) number of words are equal.

@lemire
Copy link
Member

lemire commented Jan 24, 2023

I agree.

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 a pull request may close this issue.

2 participants