You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Resources.Resx code readability and style issues #216
Currently there is an issue with code style consistency in System.Resources.Resx... family (like using BCL types instead of keywords), and in some places the readability of the code could be improved. For example, use foreach instead of for, or remove redundant else conditions. Also some patterns like str != null && str.Length > 0, or .Equals can be simplified.
I realize the specific example of for versus foreach is not the primary point of this post, but I wanted to chime in and say that there are certainly cases where you might sacrifice some readability for better performing code.
For example, for loops on List are a bit more than 2 times cheaper than foreach loops on List. This is also the case with arrays.
So it may become important to delve more deeply into these issues. Premature optimization is certainly a root of evil here, so the discussion may require some conjecture about the existing code's performance as well as how closely these code paths are to core behaviors.
Absolute. I would even go so far to say: Before we would accept PRs which 'optimize' code in terms of standards/readability, we'd need benchmark proof that the modification doesn't hurt performance.
Absolute. I would even go so far to say: Before we would accept PRs which 'optimize' code in terms of standards/readability, we'd need benchmark proof that the modification doesn't hurt performance.
@KlausLoeffelmann I think that should not be necessary for this particular PR, as I've gone through it manually and can guarantee the benefit here. However, I agree that we absolutely need bench marking of our current performance. We have this anecdotally on a few applications but not anywhere approaching the law of large numbers nor with any real confidence about the most important / frequently-hit code paths
Activity
zsd4yr commentedon Dec 10, 2018
I realize the specific example of for versus foreach is not the primary point of this post, but I wanted to chime in and say that there are certainly cases where you might sacrifice some readability for better performing code.
For example, for loops on List are a bit more than 2 times cheaper than foreach loops on List. This is also the case with arrays.
So it may become important to delve more deeply into these issues. Premature optimization is certainly a root of evil here, so the discussion may require some conjecture about the existing code's performance as well as how closely these code paths are to core behaviors.
KlausLoeffelmann commentedon Dec 10, 2018
zsd4yr commentedon Dec 10, 2018
@KlausLoeffelmann I think that should not be necessary for this particular PR, as I've gone through it manually and can guarantee the benefit here. However, I agree that we absolutely need bench marking of our current performance. We have this anecdotally on a few applications but not anywhere approaching the law of large numbers nor with any real confidence about the most important / frequently-hit code paths