Yes it will, and it also needs to create an whole copy of the array in order to reverse it - there's no reverse iterator being created here.
Often times the performance impact from doing this will be negligible, but it's also pretty easy to avoid: just iterate over the array in reverse!
For OP's code it would look something like this:
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = assemblies.Count - 1; i <= 0; --i) {
var assembly = assemblies[i];
...
}
(For most languages you would use a reverse iterator for this, I was surprised to find that top google/stack overflow results for "C# list reverse iterate" recommend the exact index-based for loop approach that I show above.)
Does this measurably improve performance? This would still be the same Big O notation, so I’m curious how people are justifying or measuring optimizations like this.
I wouls need to check but i think both work. The reason as to why you always should you the isnot keywords as that you can overload the == != operators. So if you are using a library you woulsnt know an object is misbehaving until things start to crash and you get NullPointerExceptions
As others have said, it's font ligatures and I love them. I started with FiraCode, but there are other fonts as well.
Ligatures only change how things are displayed, the underlying text is the same. Having the cursor in the middle of ≠ is a bit weird for a day, then you get used to it.
It has ligatures enabled. Pretty much all modern editors/ides/terminals have the option if you use a proper font like Fira code, jetbrains mono, cascadia code etc
public static Type GetTypeByName(string name)
{
foreach (var assembly in AppDomain.CurrentComain.GetAssemblies().Reverse())
{
var tt = assembly.GetType(name);
if (tt != null)
{
return tt;
}
}
throw new Exception("shit");
}
They're not as bad as they seem, most concerns I had were non issues when I actually used them. Also lol bitching about other people's font preferences
Yeah, but it's not just personal preference. Sometimes a colleague will take your machine to help you, sometimes you will be sharing your code over a call, and in neither of those situations does anyone want to look at the ugly ass ligatures.
This is why i refuse to make most of my projects open source. Theres so many swear words i forgot to remove i might aswell remake the project if i want it open source
67
u/v_maria Feb 22 '23
why is the list looped through in reverse
7
u/TotallyRealDev Feb 22 '23
Worst part it checking for null using != and not
is nulloris not null5
u/the96jesterrace Feb 22 '23
How is there an actual ≠ sign? Sorry for dumbing dumb questions btw, I live in .net Framework 4.5 :(
98
u/Mars_Bear2552 Feb 22 '23
Well shit
36
u/kingslayerer Feb 22 '23
why != look like that?
19
u/RichCorinthian Feb 22 '23
PR rejected—don’t throw System.Exception. Use a more specific exception type but leave the profanity. Thanks!
12
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 22 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
28
u/waiting4op2deliver Feb 22 '23
eww ligatures
2
u/M8Ir88outOf8 Feb 22 '23
Is that a != or a !== ?
2
u/mortlerlove420 Feb 22 '23
Excuse my question, but what plugin transforms the unequals operator into that nice symbol?
1
u/JourneymanInvestor Feb 22 '23
Looks fine to me.
1
u/itsTyrion Mar 21 '23
I love that exception
0
u/alydnhrealgang Feb 23 '23
-13
u/RoseboysHotAsf Feb 22 '23
This is why i refuse to make most of my projects open source. Theres so many swear words i forgot to remove i might aswell remake the project if i want it open source