From 60bc2979404d53de24926c02ae4471a73f91a53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 24 Feb 2025 10:39:16 +0100 Subject: [PATCH] refactor: one less tmp use case --- R/plot.common.R | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/R/plot.common.R b/R/plot.common.R index 40e5d68924..f5342fae70 100644 --- a/R/plot.common.R +++ b/R/plot.common.R @@ -556,11 +556,18 @@ i.get.arrow.mode <- function(graph, arrow.mode = NULL) { } if (is.character(arrow.mode)) { - tmp <- numeric(length(arrow.mode)) - tmp[arrow.mode %in% c("<", "<-")] <- 1 - tmp[arrow.mode %in% c(">", "->")] <- 2 - tmp[arrow.mode %in% c("<>", "<->")] <- 3 - arrow.mode <- tmp + arrow.mode <- map_dbl( + arrow.mode, + \(x) switch( + x, + "<" = 1, + "<-" = 1, + ">" = 2, + "->" = 2, + "<>" = 3, + "<->" = 3 + ) + ) } if (is.null(arrow.mode)) {