CompiledExpression
effectively just wraps a Value
and handles caching the variableValues
array to minimize allocations. This makes it thread-unsafe, but in the previous update, the entire expression tree is now decoupled from the CompiledExpression
since variable values are passed through an array function parameter rather than having Variable
objects store a reference to the expression they belong to. This means that clone()
can now reuse the same Value
instance, effectively only cloning the wrapper that caches the array.
The benefit of this is that it is now O(1)
to clone a CompiledExpression, whereas before it would take longer the larger the expression is, and require far more allocations. It should be virtually free to multithread with Crunch now.