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

Don't allocate temporary buffer in SmallPersistentVector.removeAll #136

Closed

Conversation

mcpiroman
Copy link
Contributor

Actually we can avoid the buffer altogether and use 32-bit mask to track retained/removed elements.

Alternative to #134

Again, I don't know which one is faster as I don't run the actual benchmarks

// Align the mask to the left
retainedMask = retainedMask shl (Int.SIZE_BITS - size)

val newBuffer = bufferOfSize(newSize)
Copy link
Member

Choose a reason for hiding this comment

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

It could probably make sense to create the new buffer as buffer.copyOf(newSize) to avoid zeroing elements in the newly created buffer and then skip first retained elements there. But that's a guess as well, needs to be benchmarked.

@qurbonzoda
Copy link
Contributor

Moved review here: #164

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.

None yet

3 participants