Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-462552: "multiple enumeration" possible improvement

$
0
0
Reporter Olga Rodygina (olgarodygina) Olga Rodygina (olgarodygina)
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:

// Avoid multiple enumeration 
myParam = myParam as IReadOnlyCollection<string> ?? myParam.ToList();

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>