Describe the solution you'd like
When I add a handler to the list, if the list is null, I first do new(), and then I add the new handler. If the list is null, there is a constructor overload to List<> that takes a IEnumerable<T> (and also checks/casts to ICollection<T>). It might be more efficient to, instead of what I'm currently doing:
if (this.Expectations.handlers0 is null ) { this.Expectations.handlers0 = new(); }
this.Expectations.handlers0.Add(@handler);
...to do this instead:
if (this.Expectations.handlers0 is null ) { this.Expectations.handlers0 = new([@handler]); }
else { this.Expectations.handlers0.Add(@handler); }
This would be a micro-optimization at best, so I won't do this unless I can see a clear "win" with this approach.
Describe the solution you'd like
When I add a handler to the list, if the list is
null, I first donew(), and then I add the new handler. If the list isnull, there is a constructor overload toList<>that takes aIEnumerable<T>(and also checks/casts toICollection<T>). It might be more efficient to, instead of what I'm currently doing:...to do this instead:
This would be a micro-optimization at best, so I won't do this unless I can see a clear "win" with this approach.