Bald Bearded Builder
csharp/tolower-is-killing-your-app-performance

ToLower is Killing your App Performance!

`Task.Wait` blocks its thread, while `await` releases that thread for other work until the operation completes.

Loads from YouTube when you press play

Transcript 1 topic

Use ordinal comparisons

0:00

Quick win time. If you're doing something like this to compare strings, please stop. You're allocating new strings. You're making your garbage collector cry. It's less efficient.

And in some cultures, it's just plain wrong. For plain old pattern matching, let's use string comparison with ordinal ignore case. Here's our fix using a string comparison. Now in our case, we're using ordinal ignore case, but you need to pick the one that's right for your situation. The best part is that also works with other string methods like equals, starts with, ends with, and all their other friends.

And that's it. Faster, safer string comparisons with no extra strings and your garbage collector can breathe a sigh of relief.

Sign in to join in. Reading needs nothing.