Skip to content

Commit 1d292a2

Browse files
committed
Simplify code paths
1 parent 4df4260 commit 1d292a2

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

r/R/dplyr-funcs-conditional.R

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,14 @@ build_case_when_expr <- function(query, value) {
8282
#' @keywords internal
8383
#' @noRd
8484
build_match_expr <- function(x, match_value) {
85-
# Expressions: use equality directly
86-
if (inherits(match_value, "Expression")) {
85+
# Expressions or length-1 non-NA: use equality directly
86+
if (inherits(match_value, "Expression") || length(match_value) == 1 && !is.na(match_value)) {
8787
return(x == match_value)
8888
}
8989

9090
# R scalar NA requires is.na() since x == NA returns NA in Arrow
91-
if (length(match_value) == 1 && is.na(match_value)) {
92-
return(call_binding("is.na", x))
93-
}
94-
95-
# R scalar: simple equality
9691
if (length(match_value) == 1) {
97-
return(x == match_value)
92+
return(call_binding("is.na", x))
9893
}
9994

10095
# R vector: use %in%, handling NA separately if present

0 commit comments

Comments
 (0)