Gendarme.Rules.Performance.MathMinMaxCandidateRule Class
This rule checks methods for code which seems to duplicate Math.Min or Math.Max. The JIT can inline these methods and generate better code for, at least some types, than it can for a custom inline implementation.

See Also: MathMinMaxCandidateRule Members

Syntax

[Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine, Gendarme.Framework, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null))]
[Gendarme.Framework.Problem("This method seems to include code duplicating Math.Min or Math.Max functionality.")]
[Gendarme.Framework.Solution("The JIT can (sometimes) generate better code for Math.Min and Math.Max methods than it can for hand-written versions.")]
public class MathMinMaxCandidateRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule

Remarks

This rule is available since Gendarme 2.0

Example

Bad example:

Example

            int max = (a > b) ? a : b;
            

Example

Good example:

Example

            int max = Math.Max (a, b);
            

Requirements

Namespace: Gendarme.Rules.Performance
Assembly: Gendarme.Rules.Performance (in Gendarme.Rules.Performance.dll)
Assembly Versions: 2.8.0.0