Skip to content

Commit b07eb2f

Browse files
committed
perf: use more anyNA() and anyDuplicated()
1 parent 031bc26 commit b07eb2f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

R/log_levels.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ unlabel_levels <- function(
388388
stop("Expected character 'labels'")
389389

390390
res <- log_levels[match(labels, names(log_levels))]
391-
if (!is.null(names(labels)) && any(is.na(res))){
391+
if (!is.null(names(labels)) && anyNA(res)){
392392
res[is.na(res)] <- as.integer(names(labels)[is.na(res)])
393393
}
394394

R/utils-sfmisc.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,15 @@ is_candidate_key <- function(x){
445445
# !is.infinite instead of is.finite because x can be a character vector
446446
length(x) > 1 &&
447447
all(!is.infinite(x)) &&
448-
!any(is.na(x)) &&
448+
!anyNA(x) &&
449449
identical(length(unique(x)), length(x))
450450
} else if (is.list(x)){
451451
length(x) > 0 &&
452452
length(x[[1]] > 0) &&
453453
do.call(is_equal_length, x) &&
454454
all(vapply(x, function(.x) all(!is.infinite(.x)), logical(1))) &&
455-
all(vapply(x, function(.x) !any(is.na(.x)), logical(1))) &&
456-
!any(duplicated(as.data.frame(x)))
455+
all(vapply(x, function(.x) !anyNA(.x), logical(1))) &&
456+
!anyDuplicated(as.data.frame(x)) > 0
457457
}
458458
}
459459

0 commit comments

Comments
 (0)