boa
boa copied to clipboard
Investigate optimization of parameter parsing in function constructors
For the function constructors we need to parse paramters at runtime e.g.:
const f = Function("a", "b = 1", "console.log(a, b, 'function body')")
f("argA") // argA 1 function body
Currently this is done by concatinating the arguments to a string and parsing that as a paramter list: https://github.com/boa-dev/boa/blob/main/boa_engine/src/builtins/function/mod.rs#L485-L502
We should investigate if this can be done in a more efficient way without the concatination. The best case would be to reuse as much of the existing parser code as possible. The solution should not introduce loads of new complexity.
Based on discussion here: https://github.com/boa-dev/boa/pull/2174#discussion_r919528091