Reporter |
|
---|---|
Created | Jan 13, 2017, 4:08:13 PM |
Updated | Aug 1, 2019, 11:16:11 PM |
Subsystem | Refactorings |
Assignee | Alisa Afonina (alisa.afonina) |
Priority | Normal |
State | Submitted |
Type | Feature |
Fix version | Backlog |
Affected versions | 2019.1 |
Fixed In EAP | Undefined |
VsVersion | All Versions |
Branch | No branch |
A possible improvement! When correcting "multiple enumeration", you use IList<T>, while IReadonlyCollection<T> is enough. We want the smallest possible divergence from IEnumerable<T>, while avoiding multiple deferred execution. IReadonlyCollection<T> is precisely that, by its Count property, which is its only difference from IEnumerable<T>.
Also, assigning to a different variable should not be necessary.
The improved refactor would look as follows:
Also, assigning to a different variable should not be necessary.
The improved refactor would look as follows:
// Avoid multiple enumeration
myParam = myParam as IReadOnlyCollection<string> ?? myParam.ToList();