Cache StringBuilder per thread and remove Lazy from GetRuntimeClassName.#1381
Conversation
| return _runtimeClassName; | ||
| } | ||
|
|
||
| public string RuntimeClassName => _runtimeClassName ?? MakeRuntimeClassName(); |
There was a problem hiding this comment.
Nit: can simplify this by just moving the code for MakeRuntimeClassName in the getter (using a body), rather than needing the separate method there, which is only ever used here anyway?
There was a problem hiding this comment.
This is the pattern followed elsewhere so sticking with that.
There was a problem hiding this comment.
But it's... Not a great pattern? And it's also wasteful (more IL size and extra JIT work for no reason), not to mention unnecessarily verbose. We should try to improve the codebase as we find things, rather than just sticking to existing code patterns that are not good in the first place. Of course, this can be a follow up 🙂
There was a problem hiding this comment.
I'm not saying that we shouldn't change it but I'd rather change it everywhere at the same time :).
Remove uses of Lazy in InspectableInfo and uses a StringBuilder cache per thread to reduce memory waste for GetRuntimeClassName.