Skip to content

Commit

Permalink
Initialize vectors with a capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Trinquier committed Feb 24, 2019
1 parent 257d235 commit 344379a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rust/arrow/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ impl From<ArrayDataRef> for BinaryArray {

impl<'a> From<Vec<&'a str>> for BinaryArray {
fn from(v: Vec<&'a str>) -> Self {
let mut offsets = vec![];
let mut values = vec![];
let mut offsets = Vec::with_capacity(v.len() + 1);
let mut values = Vec::new();
let mut length_so_far = 0;
offsets.push(length_so_far);
for s in &v {
Expand All @@ -629,8 +629,8 @@ impl<'a> From<Vec<&'a str>> for BinaryArray {

impl<'a> From<Vec<&[u8]>> for BinaryArray {
fn from(v: Vec<&[u8]>) -> Self {
let mut offsets = vec![];
let mut values = vec![];
let mut offsets = Vec::with_capacity(v.len() + 1);
let mut values = Vec::new();
let mut length_so_far = 0;
offsets.push(length_so_far);
for s in &v {
Expand Down

0 comments on commit 344379a

Please sign in to comment.