Use string.IsNullOrEmpty and ArgumentException.ThrowIfNullOrEmpty in many more places#85858
Conversation
|
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsWe have an analyzer for ThrowIfNullOrEmpty; I'll separately look into why it wasn't firing. We should consider an analyzer for string.IsNullOrEmpty. There's no perf benefit today, other than smaller IL, but the resulting code is easier to read IMHO, and there can be a benefit in the few cases where a complicated expression is duplicated and the JIT can't CSE the whole thing.
|
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
|
Unfortunately, forward substitution still does not handle |
Is this just a general comment or is this relevant to the changes made in this PR? This PR didn't remove any uses of |
In this case the number of returns matches. |
Yes, but again, where in this PR is there code that does that? (And even if there is an example or two, it doesn't matter in practice... and even if it did matter in practice, that's an issue to be addressed in the JIT, not by changing the code a developer would write to avoid idiomatic patterns.) |
We have an analyzer for ThrowIfNullOrEmpty; I'll separately look into why it wasn't firing.
We should consider an analyzer for string.IsNullOrEmpty. There's no perf benefit today, other than smaller IL, but the resulting code is easier to read IMHO, and there can be a benefit in the few cases where a complicated expression is duplicated and the JIT can't CSE the whole thing.