Skip to content

Commit

Permalink
ARROW-12504: Buffer::from_slice_ref set correct capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Apr 22, 2021
1 parent 74d3567 commit b03f2ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arrow/src/buffer/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ impl Buffer {
/// Initializes a [Buffer] from a slice of items.
pub fn from_slice_ref<U: ArrowNativeType, T: AsRef<[U]>>(items: &T) -> Self {
let slice = items.as_ref();
let len = slice.len();
let mut buffer = MutableBuffer::with_capacity(len);
let capacity = slice.len() * std::mem::size_of::<T>();
let mut buffer = MutableBuffer::with_capacity(capacity);
buffer.extend_from_slice(slice);
buffer.into()
}
Expand Down

0 comments on commit b03f2ba

Please sign in to comment.