Jaa


CA1809: Avoid excessive locals

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Item Value
RuleId CA1809
Category Microsoft.Performance
Breaking change Non-breaking

Cause

A member contains more than 64 local variables, some of which might be compiler-generated.

Note

This rule has been deprecated. For more information, see Deprecated rules.

Rule description

A common performance optimization is to store a value in a processor register instead of in memory, which is referred to as enregistering the value. The common language runtime considers up to 64 local variables for enregistration. Variables that are not enregistered are put on the stack and must be moved to a register before manipulation. To allow the chance that all local variables get enregistered, limit the number of local variables to 64.

How to fix violations

To fix a violation of this rule, refactor the implementation to use no more than 64 local variables.

When to suppress warnings

It is safe to suppress a warning from this rule, or to disable the rule, if performance is not an issue.

CA1804: Remove unused locals