opt_common_subexpr: Optimizer: Common Subexpression Elimination.

Description Usage Arguments Examples

View source: R/opt-common-subexpr.R

Description

Performs one common subexpression elimination pass. Carefully examine the results after running this function!

Usage

1
opt_common_subexpr(texts, n_values = 2, in_fun_call = FALSE)

Arguments

texts

A list of character vectors with the code to optimize.

n_values

A numeric indicating the minimum number of values to consider a subexpression.

in_fun_call

A logical indicating whether it should propagate in function calls. Note: this could change the semantics of the program.

Examples

1
2
3
4
5
6
code <- paste(
  "a <- b * c + g",
  "d = b * c * e",
  sep = "\n"
)
cat(opt_common_subexpr(list(code))$codes[[1]])

rco documentation built on April 17, 2021, 5:06 p.m.