Skip to content

Commit 64a5146

Browse files
Rachelintcipherstakes
authored andcommitted
add or_fun_call and unnecessary_lazy_evaluations lints on core, and fix bad cases. (apache#15807)
1 parent 1ea6ab0 commit 64a5146

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

datafusion/core/src/datasource/listing/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl ListingTable {
799799
/// If `None`, creates a new [`DefaultFileStatisticsCache`] scoped to this query.
800800
pub fn with_cache(mut self, cache: Option<FileStatisticsCache>) -> Self {
801801
self.collected_statistics =
802-
cache.unwrap_or(Arc::new(DefaultFileStatisticsCache::default()));
802+
cache.unwrap_or_else(|| Arc::new(DefaultFileStatisticsCache::default()));
803803
self
804804
}
805805

datafusion/core/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@
2222
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2323
// Make sure fast / cheap clones on Arc are explicit:
2424
// https://github.com/apache/datafusion/issues/11143
25-
#![cfg_attr(not(test), deny(clippy::clone_on_ref_ptr))]
25+
//
26+
// Eliminate unnecessary function calls(some may be not cheap) due to `xxx_or`
27+
// for performance. Also avoid abusing `xxx_or_else` for readability:
28+
// https://github.com/apache/datafusion/issues/15802
29+
#![cfg_attr(
30+
not(test),
31+
deny(
32+
clippy::clone_on_ref_ptr,
33+
clippy::or_fun_call,
34+
clippy::unnecessary_lazy_evaluations
35+
)
36+
)]
2637
#![warn(missing_docs, clippy::needless_borrow)]
2738

2839
//! [DataFusion] is an extensible query engine written in Rust that

0 commit comments

Comments
 (0)