Skip to content

Commit a511f02

Browse files
committed
Revert with_capacity for collections with a fixed literal size
1 parent 32af0e2 commit a511f02

5 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎datafusion-cli/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl ByteUnit {
448448
fn parse_size_string(size: &str, label: &str) -> Result<usize, String> {
449449
static BYTE_SUFFIXES: LazyLock<HashMap<&'static str, ByteUnit>> =
450450
LazyLock::new(|| {
451-
let mut m = HashMap::with_capacity(9);
451+
let mut m = HashMap::new();
452452
m.insert("b", ByteUnit::Byte);
453453
m.insert("k", ByteUnit::KiB);
454454
m.insert("kb", ByteUnit::KiB);

‎datafusion-cli/src/object_storage.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ impl ExtensionOptions for AwsOptions {
421421
}
422422
}
423423

424-
let mut v = Visitor(Vec::with_capacity(6));
424+
let mut v = Visitor(vec![]);
425425
self.access_key_id.visit(&mut v, "access_key_id", "");
426426
self.secret_access_key
427427
.visit(&mut v, "secret_access_key", "");
@@ -506,7 +506,7 @@ impl ExtensionOptions for GcpOptions {
506506
}
507507
}
508508

509-
let mut v = Visitor(Vec::with_capacity(3));
509+
let mut v = Visitor(vec![]);
510510
self.service_account_path
511511
.visit(&mut v, "service_account_path", "");
512512
self.service_account_key

‎datafusion/core/src/execution/session_state_defaults.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl SessionStateDefaults {
5050
/// returns a map of the default [`TableProviderFactory`]s
5151
pub fn default_table_factories() -> HashMap<String, Arc<dyn TableProviderFactory>> {
5252
let mut table_factories: HashMap<String, Arc<dyn TableProviderFactory>> =
53-
HashMap::with_capacity(6);
53+
HashMap::new();
5454
#[cfg(feature = "parquet")]
5555
table_factories.insert("PARQUET".into(), Arc::new(DefaultTableFactory::new()));
5656
table_factories.insert("CSV".into(), Arc::new(DefaultTableFactory::new()));

‎datafusion/functions-nested/src/map.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,8 @@ fn make_map_batch_internal(
287287

288288
let key_field = Arc::new(Field::new("key", keys.data_type().clone(), false));
289289
let value_field = Arc::new(Field::new("value", values.data_type().clone(), true));
290-
let mut entry_struct_buffer: VecDeque<(Arc<Field>, ArrayRef)> =
291-
VecDeque::with_capacity(2);
292-
let mut entry_offsets_buffer = VecDeque::with_capacity(2);
290+
let mut entry_struct_buffer: VecDeque<(Arc<Field>, ArrayRef)> = VecDeque::new();
291+
let mut entry_offsets_buffer = VecDeque::new();
293292
entry_offsets_buffer.push_back(0);
294293

295294
entry_struct_buffer.push_back((Arc::clone(&key_field), Arc::clone(keys)));

‎datafusion/physical-plan/src/joins/symmetric_hash_join.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ impl OneSideHashJoiner {
15691569
}
15701570
// Process the build and probe side sorted filter expressions if both are present:
15711571
// Collect the sorted filter expressions into a vector of (node_index, interval) tuples:
1572-
let mut filter_intervals = Vec::with_capacity(2);
1572+
let mut filter_intervals = vec![];
15731573
for expr in [
15741574
&build_side_sorted_filter_expr,
15751575
&probe_side_sorted_filter_expr,

0 commit comments

Comments
 (0)