opt_loop_invariant {rco} | R Documentation |
Optimizer: Loop-invariant Code Motion.
Description
Performs one loop-invariant code motion pass. Carefully examine the results after running this function!
Usage
opt_loop_invariant(texts)
Arguments
texts |
A list of character vectors with the code to optimize. |
Examples
code <- paste(
"i <- 0",
"while (i < n) {",
" x <- y + z",
" a[i] <- 6 * i + x * x",
" i <- i + 1",
"}",
sep = "\n"
)
cat(opt_loop_invariant(list(code))$codes[[1]])
[Package rco version 1.0.2 Index]