Skip to content

Commit 64b59c7

Browse files
committed
Flatten call to map2() for better profiling
1 parent 50a840d commit 64b59c7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

R/transform-files.R

+12-7
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,20 @@ parse_transform_serialize_r <- function(text,
244244
transformers
245245
)
246246

247-
text_out <- pd_nested %>%
248-
split(pd_nested$block) %>%
249-
unname() %>%
250-
map2(find_blank_lines_to_next_block(pd_nested),
251-
parse_transform_serialize_r_block,
247+
pd_split <- unname(split(pd_nested, pd_nested$block))
248+
pd_blank <- find_blank_lines_to_next_block(pd_nested)
249+
250+
text_out <- vector("list", length(pd_split))
251+
for (i in seq_along(pd_split)) {
252+
text_out[[i]] <- parse_transform_serialize_r_block(
253+
pd_split[[i]],
254+
pd_blank[[i]],
252255
transformers = transformers,
253256
base_indention = base_indention
254-
) %>%
255-
unlist()
257+
)
258+
}
259+
260+
text_out <- unlist(text_out)
256261

257262
verify_roundtrip(
258263
text, text_out,

0 commit comments

Comments
 (0)