Performs one memory allocation pass. Carefully examine the results after running this function!
opt_memory_alloc(code)
code | A list of character vectors with the code to optimize. |
---|
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 #> }