Lazily realize IOperation.ConstantValue
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.
Showing
因为 它太大了无法显示 source diff 。你可以改为 查看blob。
此差异已折叠。
此差异已折叠。
想要评论请 注册 或 登录