From 8c4ec275a9e2bda5d93be44ad4e28f29ecb4d218 Mon Sep 17 00:00:00 2001 From: Marco Neumann Date: Tue, 30 Aug 2022 11:15:49 +0200 Subject: [PATCH] fix: speed up `ConfigOptions` creation Fixes #3295. --- datafusion/core/src/config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datafusion/core/src/config.rs b/datafusion/core/src/config.rs index 054c66bf5d65..3c828079e241 100644 --- a/datafusion/core/src/config.rs +++ b/datafusion/core/src/config.rs @@ -207,8 +207,8 @@ impl Default for ConfigOptions { impl ConfigOptions { /// Create new ConfigOptions struct pub fn new() -> Self { - let mut options = HashMap::new(); let built_in = BuiltInConfigs::new(); + let mut options = HashMap::with_capacity(built_in.config_definitions.len()); for config_def in &built_in.config_definitions { options.insert(config_def.key.clone(), config_def.default_value.clone()); } @@ -216,10 +216,10 @@ impl ConfigOptions { } /// Create new ConfigOptions struct, taking values from environment variables where possible. - /// For example, setting DATAFUSION_EXECUTION_BATCH_SIZE to control `datafusion.execution.batch_size`. + /// For example, setting `DATAFUSION_EXECUTION_BATCH_SIZE` to control `datafusion.execution.batch_size`. pub fn from_env() -> Self { - let mut options = HashMap::new(); let built_in = BuiltInConfigs::new(); + let mut options = HashMap::with_capacity(built_in.config_definitions.len()); for config_def in &built_in.config_definitions { let config_value = { let mut env_key = config_def.key.replace('.', "_");