Apache DataFusion SQL Query Engine
add `or_fun_call` and `unnecessary_lazy_evaluations` lints on `core`, and fix bad cases. (#15807)
kamille2f7cc9beb15c
diff --git a/datafusion/core/src/datasource/listing/table.rs b/datafusion/core/src/datasource/listing/table.rsindex f32a32355c..a9834da92e 100644--- a/datafusion/core/src/datasource/listing/table.rs+++ b/datafusion/core/src/datasource/listing/table.rs@@ -799,7 +799,7 @@ impl ListingTable {/// If `None`, creates a new [`DefaultFileStatisticsCache`] scoped to this query.pub fn with_cache(mut self, cache: Option<FileStatisticsCache>) -> Self {self.collected_statistics =- cache.unwrap_or(Arc::new(DefaultFileStatisticsCache::default()));+ cache.unwrap_or_else(|| Arc::new(DefaultFileStatisticsCache::default()));self}diff --git a/datafusion/core/src/lib.rs b/datafusion/core/src/lib.rsindex 6af72e6be9..928efd533c 100644--- a/datafusion/core/src/lib.rs+++ b/datafusion/core/src/lib.rs@@ -22,7 +22,18 @@#![cfg_attr(docsrs, feature(doc_auto_cfg))]// Make sure fast / cheap clones on Arc are explicit:// https://github.com/apache/datafusion/issues/11143-#![cfg_attr(not(test), deny(clippy::clone_on_ref_ptr))]+//+// Eliminate unnecessary function calls(some may be not cheap) due to `xxx_or`+// for performance. Also avoid abusing `xxx_or_else` for readability:+// https://github.com/apache/datafusion/issues/15802+#![cfg_attr(+ not(test),+ deny(+ clippy::clone_on_ref_ptr,+ clippy::or_fun_call,+ clippy::unnecessary_lazy_evaluations+ )+)]#![warn(missing_docs, clippy::needless_borrow)]//! [DataFusion] is an extensible query engine written in Rust that