Skip to content

perf: avoid re-allocation if buffer is not shared - #10438

Open
Rich-T-kid wants to merge 1 commit into
apache:mainfrom
Rich-T-kid:rich-T-kid/optimize-take-n-boolBuff
Open

perf: avoid re-allocation if buffer is not shared#10438
Rich-T-kid wants to merge 1 commit into
apache:mainfrom
Rich-T-kid:rich-T-kid/optimize-take-n-boolBuff

Conversation

@Rich-T-kid

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

If a boolean buffer is not shared we should re-use its allocation instead of building a new builder from scratch.

What changes are included in this PR?

match on into_mutable, in the error case the old path is taken. If the buffer can be re-used we use it directly.

Are these changes tested?

yes, existing test cover this behavior

Are there any user-facing changes?

no

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 26, 2026
Comment on lines +599 to +601
for i in end..len {
bit_util::unset_bit(mutable_buffer.as_slice_mut(), i);
}

@Rich-T-kid Rich-T-kid Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Im sure there are faster ways to do this. I looked up a few ways to do this and im not too familar with bit operations so I left is as a basic loop for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use Buffer.into_mutable to reuse the allocation if possible in take_n_true

1 participant