I read in CLR via C# by Jeffrey Richter that String.ToUpperInvariant()
is faster than String.ToLowerInvariant()
. He says that this is because the FCL uses ToUpperInvariant to normalise strings, so the method is ultra-optimised. Running a couple quick tests on my machine, I concur that ToUpperInvariant()
is indeed slightly faster.
My question is if anybody knows how the function is actually optimised on a technical level, and/or why the same optimisations were not applied to ToLowerInvariant()
as well.
Concerning the "duplicate": The proposed "duplicate" question really doesn't provide an answer to my question. I understand the benefits of using ToUpperInvariant
instead of ToLowerInvariant
, but what I would like to know is how/why ToUpperInvariant
performs better. This point is not addressed in the "duplicate".