Skip to content

Commit

Permalink
Merge pull request #728 from m-muecke/fixed
Browse files Browse the repository at this point in the history
perf: add missing fixed for fixed strings
  • Loading branch information
gaborcsardi authored Oct 3, 2024
2 parents 1220ed0 + 5924a61 commit fbec918
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion R/aaa-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ tail_na <- function(x, n = 1) {
}

dedent <- function(x, n = 2) {
first_n_char <- strsplit(ansi_substr(x, 1, n), "")[[1]]
first_n_char <- strsplit(ansi_substr(x, 1, n), "", fixed = TRUE)[[1]]
n_space <- cumsum(first_n_char == " ")
d_n_space <- diff(c(0, n_space))
first_not_space <- utils::head(c(which(d_n_space == 0), n + 1), 1)
Expand Down
2 changes: 1 addition & 1 deletion R/aab-rstudio-detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ rstudio <- local({
"rstudio_build_pane"

} else if (new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
grepl("rstudio", new$envs[["XPC_SERVICE_NAME"]])) {
grepl("rstudio", new$envs[["XPC_SERVICE_NAME"]], fixed = TRUE)) {
# RStudio job, XPC_SERVICE_NAME=0 in the subprocess of a job
# process. Hopefully this is reliable.
"rstudio_job"
Expand Down
2 changes: 1 addition & 1 deletion R/ansi-hyperlink.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ abs_path1 <- function(x) {
# -- {.fun} ---------------------------------------------------------------

make_link_fun <- function(txt) {
tolink <- grepl("::", txt)
tolink <- grepl("::", txt, fixed = TRUE)
linked <- grepl("\007|\033\\\\", txt)
todo <- tolink & !linked
if (!any(todo)) return(txt)
Expand Down
2 changes: 1 addition & 1 deletion R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ is_border_style <- function(x) {
}

is_padding_or_margin <- function(x) {
is.numeric(x) && length(x) %in% c(1, 4) && all(!is.na(x)) &&
is.numeric(x) && length(x) %in% c(1, 4) && !anyNA(x) &&
all(as.integer(x) == x)
}

Expand Down
6 changes: 3 additions & 3 deletions R/cliapp.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ clii_alert <- function(app, type, text, id, class, wrap) {
style <- app$get_current_style()
before <- call_if_fun(style$before) %||% ""
after <- call_if_fun(style$after) %||% ""
before <- gsub(" ", "\u00a0", before)
after <- gsub(" ", "\u00a0", after)
before <- gsub(" ", "\u00a0", before, fixed = TRUE)
after <- gsub(" ", "\u00a0", after, fixed = TRUE)
text[1] <- paste0(before, text[1])
text[length(text)] <- paste0(text[length(text)], after)
if (is.function(style$fmt)) text <- style$fmt(text)
Expand All @@ -277,7 +277,7 @@ clii_bullets <- function(app, text, id, class) {
length(nms) <- length(text)
nms[is.na(nms) | nms == ""] <- "empty"
nms[nms == " "] <- "space"
nms <- gsub(" ", "-", nms)
nms <- gsub(" ", "-", nms, fixed = TRUE)
# cls is vectorized here (!)
cls <- paste0("bullet memo-item bullet-", nms, " memo-item=", nms)

Expand Down
2 changes: 1 addition & 1 deletion R/glue.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ collapse_head <- function(x, sep, sep2, last, trunc, width, ellipsis) {
# special cases that do not need trimming
if (lnx == 0L) {
return("")
} else if (any(is.na(x))) {
} else if (anyNA(x)) {
return(NA_character_)
}

Expand Down
4 changes: 2 additions & 2 deletions R/hash.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ hash_emoji1 <- function(x, size = 3) {

hash_emoji1_transform <- function(md5, size) {
md513 <- substr(md5, 1, 13)
mdint <- as.integer(as.hexmode(strsplit(md513, "")[[1]]))
mdint <- as.integer(as.hexmode(strsplit(md513, "", fixed = TRUE)[[1]]))
hash <- sum(mdint * 16^(0:12))

base <- nrow(emojis)
Expand Down Expand Up @@ -444,7 +444,7 @@ hash_animal1 <- function(x, n_adj = 2) {

hash_animal1_transform <- function(md5, n_adj) {
md513 <- substr(md5, 1, 13)
mdint <- as.integer(as.hexmode(strsplit(md513, "")[[1]]))
mdint <- as.integer(as.hexmode(strsplit(md513, "", fixed = TRUE)[[1]]))
hash <- sum(mdint * 16^(0:12))

len_ani <- length(gfycat_animals)
Expand Down
2 changes: 1 addition & 1 deletion R/internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ clii__xtext <- function(app, text, .list, indent, padding, ln = TRUE, wrap = TRU
text <- app$inline(text, .list = .list)
exdent <- style$`text-exdent` %||% 0L

esc <- function(x) gsub(" ", "\u00a0", x)
esc <- function(x) gsub(" ", "\u00a0", x, fixed = TRUE)

bef <- call_if_fun(style$before)
if (!is.null(bef)) text[1] <- paste0(esc(bef), text[1])
Expand Down
2 changes: 1 addition & 1 deletion R/num-ansi-colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ emacs_version <- function() {
ver <- Sys.getenv("INSIDE_EMACS")
if (ver == "") return(NA_integer_)

ver <- gsub("'", "", ver)
ver <- gsub("'", "", ver, fixed = TRUE)

ver <- strsplit(ver, ",", fixed = TRUE)[[1]]
ver <- strsplit(ver, ".", fixed = TRUE)[[1]]
Expand Down
8 changes: 4 additions & 4 deletions R/prettycode.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ code_theme_make <- function(theme) {
if (is.list(theme)) return(theme)
if (is_string(theme)) {
if (theme %in% names(rstudio_themes)) return(rstudio_themes[[theme]])
lcs <- gsub(" ", "_", tolower(names(rstudio_themes)))
lcs <- gsub(" ", "_", tolower(names(rstudio_themes)), fixed = TRUE)
if (theme %in% lcs) return(rstudio_themes[[ match(theme, lcs)[1] ]])
warning("Unknown cli code theme: `", theme, "`.")
return(NULL)
Expand Down Expand Up @@ -412,13 +412,13 @@ find_function_symbol <- function(name, envir = .GlobalEnv) {
while (!identical(envir, empty)) {
if (exists(name, envir = envir, inherits = FALSE, mode = "function")) {
env_name <- environmentName(envir)
if (grepl("package:", env_name)) {
if (grepl("package:", env_name, fixed = TRUE)) {
env_name <- sub("^package:", "", env_name)
}
if (grepl("imports:", env_name)) {
if (grepl("imports:", env_name, fixed = TRUE)) {
env_name <- environmentName(environment(get(name, envir)))
}
if (grepl("package:", env_name)) {
if (grepl("package:", env_name, fixed = TRUE)) {
env_name <- sub("^package:", "", env_name)
}
if (env_name %in% c("", "R_GlobalEnv")) {
Expand Down
2 changes: 1 addition & 1 deletion R/simple-theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ is_iterm_dark <- function() {
stdout = TRUE,
stderr = TRUE
))
nums <- scan(text = gsub(",", "", out), quiet = TRUE)
nums <- scan(text = gsub(",", "", out, fixed = TRUE), quiet = TRUE)
mean(nums) < 20000
})
}
Expand Down
2 changes: 1 addition & 1 deletion R/themes.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ encode_string <- function(x) {
}

quote_weird_name0 <- function(x) {
x <- gsub(" ", "\u00a0", x)
x <- gsub(" ", "\u00a0", x, fixed = TRUE)
x2 <- ansi_strip(x)

fc <- first_character(x2)
Expand Down
14 changes: 7 additions & 7 deletions R/vt.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ vt_output <- function(output, width = 80L, height = 25L) {
lineno = i,
segmentno = seq_along(segments),
segment = segs,
bold = grepl("bold;", lgs$values),
italic = grepl("italic;", lgs$values),
underline = grepl("underline;", lgs$values),
strikethrough = grepl("strikethrough;", lgs$values),
blink = grepl("blink;", lgs$values),
inverse = grepl("inverse;", lgs$values),
color= fg,
bold = grepl("bold;", lgs$values, fixed = TRUE),
italic = grepl("italic;", lgs$values, fixed = TRUE),
underline = grepl("underline;", lgs$values, fixed = TRUE),
strikethrough = grepl("strikethrough;", lgs$values, fixed = TRUE),
blink = grepl("blink;", lgs$values, fixed = TRUE),
inverse = grepl("inverse;", lgs$values, fixed = TRUE),
color = fg,
background_color = bg,
link = link,
link_params = link_params
Expand Down
2 changes: 1 addition & 1 deletion exec/up.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ up <- function(urls, timeout = 5) {
}
})$
catch(error = function(err) {
e <- if (grepl("timed out", err$message)) "timed out" else "error"
e <- if (grepl("timed out", err$message, fixed = TRUE)) "timed out" else "error"
cli_alert_danger("{.url {url}} ({e})")
})
})
Expand Down
2 changes: 1 addition & 1 deletion tools/get-rstudio-themes.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ rstudio_css <- function(theme) {

## Three digit colors are not handled by cli...
if (grepl("^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$", col)) {
col <- paste(rep(strsplit(col, "")[[1]], c(1, 2, 2, 2)), collapse = "")
col <- paste(rep(strsplit(col, "", fixed = TRUE)[[1]], c(1, 2, 2, 2)), collapse = "")
}
## rgb () form
if (grepl("^rgb", col)) {
Expand Down
8 changes: 4 additions & 4 deletions tools/spinners.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ spinners <- pdt[, c("name", "interval", "frames")]
usethis::use_data(spinners, internal = TRUE)
spinners <- rbind(
spinners,
list(name = "growVeriticalDotsLR", interval = 80, frames = strsplit("⠀⡀⣀⣄⣤⣦⣶⣷⣿⣾⣶⣴⣤⣠⣀⢀", "")),
list(name = "growVeriticalDotsRL", interval = 80, frames = strsplit("⠀⢀⣀⣠⣤⣴⣶⣾⣿⣷⣶⣦⣤⣄⣀⡀", "")),
list(name = "growVeriticalDotsLL", interval = 80, frames = strsplit("⠀⡀⣀⣄⣤⣦⣶⣷⣿⣷⣶⣦⣤⣄⣀⡀", "")),
list(name = "growVeriticalDotsRR", interval = 80, frames = strsplit("⠀⡀⣀⣠⣤⣴⣶⣾⣿⣾⣶⣴⣤⣠⣀⢀", ""))
list(name = "growVeriticalDotsLR", interval = 80, frames = strsplit("⠀⡀⣀⣄⣤⣦⣶⣷⣿⣾⣶⣴⣤⣠⣀⢀", "", fixed = TRUE)),
list(name = "growVeriticalDotsRL", interval = 80, frames = strsplit("⠀⢀⣀⣠⣤⣴⣶⣾⣿⣷⣶⣦⣤⣄⣀⡀", "", fixed = TRUE)),
list(name = "growVeriticalDotsLL", interval = 80, frames = strsplit("⠀⡀⣀⣄⣤⣦⣶⣷⣿⣷⣶⣦⣤⣄⣀⡀", "", fixed = TRUE)),
list(name = "growVeriticalDotsRR", interval = 80, frames = strsplit("⠀⡀⣀⣠⣤⣴⣶⣾⣿⣾⣶⣴⣤⣠⣀⢀", "", fixed = TRUE))
)

0 comments on commit fbec918

Please sign in to comment.