# V813. Decreased performance. The argument should probably be rendered as a constant pointer/reference.

The analyzer has detected a construct that can be optimized: an argument, which is a structure or a class, is passed into a function by value. The analyzer checks the body function and finds out that the argument is not modified. For the purpose of optimization, it can be passed as a constant reference. It may enhance the program's performance, as it is only the address that will be copied instead of the whole class object when calling the function. This optimization is especially noticeable when the class contains a large amount of data.

For example:

    void foo(Point p)
    {
      float x = p.x;
      float y = p.y;
      float z = p.z;
      float k = p.k;
      float l = p.l;
      .... 'p' argument is not used further in any way....
    }

This code is very easy to fix - you just need to change the function declaration:

    void foo(const Point &p)
    {
      float x = p.x;
      float y = p.y;
      float z = p.z;
      float k = p.k;
      float l = p.l;
      .... 'p' argument is not used further in any way....
    }

The analyzer doesn't generate the warning if structures are very small.

Note N1. The user can specify the minimal structure size starting with which the analyzer should generate its warnings.

For example, to prevent it from generating messages for structures whose size is equal to or less than 32 bytes, you can add the following comment into the code:

    //-V813_MINSIZE=33

The number 33 determines the structure size starting with which the analyzer will generate messages.

You can also write this comment in one of the global files (for example in StdAfx.h) so that it affects the whole project.

Default value: 17.

Note N2. The analyzer may make mistakes when trying to figure out whether or not a variable is being modified inside the function body. If you have noticed an obvious false positive, please send us the corresponding code sample for us to study it.

If the code is correct, you can turn off the false warning by adding the comment "//-V813".