Performs one memory allocation pass. Carefully examine the results after running this function!

opt_memory_alloc(code)

Arguments

code

A list of character vectors with the code to optimize.

Examples

code <- paste( "v <- NULL", "for (i in 1:5) {", " v[i] <- i^2", "}", sep = "\n" ) cat(opt_memory_alloc(list(code))$codes[[1]])
#> v <- vector(length = 5) #> for (i in 1:5) { #> v[i] <- i^2 #> }