• F
    Lazily realize IOperation.ConstantValue · 022b6e65
    Fredric Silberberg 提交于
    Today, we realize ConstantValues of nodes as soon as an IOperation is created. This means that for things like constant string addition, we immediately use O(n^2) memory when an IOperation tree is fully realized. Internally the compiler uses an approach to only realize the final string when necessary, and this ports IOperation to use that representation under the hood for strings. When an IOperation.ConstantValue that is a string is realized, we take a WeakReference to that string. If a subsequent request comes in and the reference has not yet expired, we return that same string to avoid duplication, but avoid rooting the object if one user requests the constant value and then immediately gets rid of it. Fixes https://github.com/dotnet/roslyn/issues/43019.
    022b6e65
OperationCloner.cs 43.8 KB