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

RSRP-296580: Missing Sum(selector) optimization suggestions

$
0
0
Reporter Yuri Astrakhan (yurik) Yuri Astrakhan (yurik)
Created Apr 20, 2012 10:22:48 PM
Updated Apr 20, 2012 10:22:48 PM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem No subsystem
Affected versions 7.0 Preview
Fixed in build No Fixed in build
Just like IEnumerable.Where(predicate).Last() should be optimized to IEnumerable.Last(predicate), Sum() and other methods that include selectors should be optimized:

static int Sum(IEnumerable<string> vals)
{
    return vals.Select(int.Parse).Sum(); // Should be converted to: vals.Sum(i => int.Parse(i));
}


The example above is slightly more complex than a straightforward conversion because int.Parse() cannot be used directly and must be used as lambda expression.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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