Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Minor code improvements suggested by newer clippy #13666

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/listing/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl ListingTableUrl {
if ignore_subdirectory {
segments
.next()
.map_or(false, |file_name| glob.matches(file_name))
.is_some_and(|file_name| glob.matches(file_name))
} else {
let stripped = segments.join(DELIMITER);
glob.matches(&stripped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ pub(crate) fn reorder_join_keys_to_inputs(
left.equivalence_properties(),
right.equivalence_properties(),
);
if positions.map_or(false, |idxs| !idxs.is_empty()) {
if positions.is_some_and(|idxs| !idxs.is_empty()) {
let JoinKeyPairs {
left_keys,
right_keys,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn plan_with_order_breaking_variants(
// not required by intermediate operators:
if maintains
&& (is_sort_preserving_merge(plan)
|| !required_ordering.map_or(false, |required_ordering| {
|| !required_ordering.is_some_and(|required_ordering| {
node.plan
.equivalence_properties()
.ordering_satisfy_requirement(&required_ordering)
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/physical_optimizer/sanity_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn check_finiteness_requirements(
/// [`PhysicalExpr`]: crate::physical_plan::PhysicalExpr
/// [`Operator`]: datafusion_expr::Operator
fn is_prunable(join: &SymmetricHashJoinExec) -> bool {
join.filter().map_or(false, |filter| {
join.filter().is_some_and(|filter| {
check_support(filter.expression(), &join.schema())
&& filter
.schema()
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/string/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub(crate) fn general_trim<T: OffsetSizeTrait>(
str::trim_start_matches::<&[char]>(input, pattern.as_ref());
// `ltrimmed_str` is actually `input`[start_offset..],
// so `start_offset` = len(`input`) - len(`ltrimmed_str`)
let start_offset = input.as_bytes().len() - ltrimmed_str.as_bytes().len();
let start_offset = input.len() - ltrimmed_str.len();

(ltrimmed_str, start_offset as u32)
},
Expand All @@ -78,7 +78,7 @@ pub(crate) fn general_trim<T: OffsetSizeTrait>(
str::trim_start_matches::<&[char]>(input, pattern.as_ref());
// `btrimmed_str` can be got by rtrim(ltrim(`input`)),
// so its `start_offset` should be same as ltrim situation above
let start_offset = input.as_bytes().len() - ltrimmed_str.as_bytes().len();
let start_offset = input.len() - ltrimmed_str.len();
let btrimmed_str =
str::trim_end_matches::<&[char]>(ltrimmed_str, pattern.as_ref());

Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/unicode/strpos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ where
// the sub vector in the main vector. This is faster than string.find() method.
if ascii_only {
// If the substring is empty, the result is 1.
if substring.as_bytes().is_empty() {
if substring.is_empty() {
T::Native::from_usize(1)
} else {
T::Native::from_usize(
string
.as_bytes()
.windows(substring.as_bytes().len())
.windows(substring.len())
.position(|w| w == substring.as_bytes())
.map(|x| x + 1)
.unwrap_or(0),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/equivalence/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ impl EquivalenceGroup {
// and the equivalence class `(a, b)`, expression `b` projects to `a1`.
if self
.get_equivalence_class(source)
.map_or(false, |group| group.contains(expr))
.is_some_and(|group| group.contains(expr))
{
return Some(Arc::clone(target));
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-plan/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub fn can_project(
if columns
.iter()
.max()
.map_or(false, |&i| i >= schema.fields().len())
.is_some_and(|&i| i >= schema.fields().len())
{
Err(arrow_schema::ArrowError::SchemaError(format!(
"project index {} out of bounds, max field {}",
Expand Down
Loading