C & C++

C & C++

By DeepSource

Implicit type promotion of float to double in a math function CXX-P2001
Performance

Calling math functions that only accept double with float arguments causes an implicit type promotion of float argument. Type promoting float to double costs extra space in memory, it also costs extra instructions for the conversion from float and lastly vectorisation of float is a lot more efficient compared to double.

Inefficient character look-up in std::string CXX-P2003
Performance

Found using sub-string based method find for a character look-up.

Unnecessary copy of non-trivially copyable type CXX-P2005
Performance

Copying an object is an expensive operation, especially if the type of the object is not trivial to copy. To avoid creating an unnecessary copy of such object, use const references.

Found copy-on-return when move-on-return is faster CXX-P2006
Performance

The analyser has found a local variable that can't be automatically moved. The reason for this behavior is the constness of the variable. Consider declaring the variable without the qualifier const.

Inefficient use of std::vector in loop CXX-P2007
Performance

Manually appending a significant number of elements to a std::vector without reserving the memory upfront can cause performance issues as the memory needs to be reallocated and copied every time the std::vector's size increases. This can be costly if many items need to be pushed into the std::vector. Consider using the std::vector::reserve() function to preallocate memory for the std::vector before a loop containing a std::vector::push_back.