From 0ce266a11c0095c09d3ddf04558ac65935031b21 Mon Sep 17 00:00:00 2001 From: wlandau Date: Tue, 7 Jan 2025 12:09:15 -0500 Subject: [PATCH] speed up condense_data() --- R/class_database.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/class_database.R b/R/class_database.R index de9f0ead..595a8d77 100644 --- a/R/class_database.R +++ b/R/class_database.R @@ -149,7 +149,12 @@ database_class <- R6::R6Class( lookup_list(.subset2(self, "lookup")) }, condense_data = function(data) { - data[!duplicated(data$name, fromLast = TRUE), ] + repeats <- duplicated(data$name, fromLast = TRUE) + if (any(repeats)) { + data[!repeats, ] + } else { + data + } }, read_condensed_data = function() { self$condense_data(self$read_data())