Skip to content

Commit 08f9ec1

Browse files
simplify and speed up (probably minor)
1 parent 14aebe0 commit 08f9ec1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/rules-indention.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ indent_op <- function(pd,
5454
indent_eq_sub <- function(pd,
5555
indent_by,
5656
token = c("EQ_SUB", "EQ_FORMALS")) {
57-
eq_sub <- which(pd$token %in% token)
58-
if (length(eq_sub) == 0) {
57+
eq_sub <- pd$token %in% token
58+
if (!any(eq_sub)) {
5959
return(pd)
6060
}
61-
has_line_break <- which(pd$lag_newlines > 0)
62-
indent_indices <- intersect(eq_sub + 1, has_line_break)
61+
has_line_break <- pd$lag_newlines > 0
62+
indent_indices <- lag(eq_sub, default = FALSE) & has_line_break
6363
pd$indent[indent_indices] <- pd$indent[indent_indices] + indent_by
6464
pd
6565
}

0 commit comments

Comments
 (0)