opt_common_subexpr {rco}R Documentation

Optimizer: Common Subexpression Elimination.

Description

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

Usage

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

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

[Package rco version 1.0.2 Index]