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

From() without a new allocation #85

Closed
dececx opened this issue Jan 3, 2021 · 3 comments · Fixed by #104
Closed

From() without a new allocation #85

dececx opened this issue Jan 3, 2021 · 3 comments · Fixed by #104

Comments

@dececx
Copy link

dececx commented Jan 3, 2021

Do you think it would be reasonable to add something like:

func (b *BitSet) SetBitsetFrom(buf []uint64) {
  b.length = ulen(len(buf)) * 64
  b.set = buf
}

It's basically From() without a new allocation. Escape analysis seems to force a heap allocation with the current From() and I'm trying to avoid it.

@lemire
Copy link
Member

lemire commented Jan 4, 2021

Sounds reasonable.

@willf
Copy link
Collaborator

willf commented Jan 5, 2021

@dececx Do you want to write a PR?

@lemire
Copy link
Member

lemire commented May 17, 2021

Note that this issue is still reasonable and could be fixed rather easily.

For people reading this, the idea is that you'd avoid creating a new Bitset instance (which From does).

SignorMercurio added a commit to SignorMercurio/bitset that referenced this issue Apr 21, 2022
lemire added a commit that referenced this issue Apr 21, 2022
add SetBitsetFrom() to resolve #85
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.

3 participants