use reserve instead of constructor

The constructor 0 initializes. reserve does not.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2021-07-08 16:27:13 -07:00
parent 63f64c5055
commit fde53df4da

View File

@ -60,7 +60,8 @@ VIPS_NAMESPACE_START
std::vector<double>
to_vectorv( int n, ... )
{
std::vector<double> vector( n );
std::vector<double> vector;
vector.reserve( n );
va_list ap;
va_start( ap, n );
@ -80,7 +81,8 @@ to_vector( double value )
std::vector<double>
to_vector( int n, double array[] )
{
std::vector<double> vector( n );
std::vector<double> vector;
vector.reserve( n );
for( std::vector<double>::size_type i = 0; i < size_t(n); i++ )
vector[i] = array[i];
@ -91,7 +93,8 @@ to_vector( int n, double array[] )
std::vector<double>
negate( std::vector<double> vector )
{
std::vector<double> new_vector( vector.size() );
std::vector<double> new_vector;
new_vector.reserve( vector.size() );
for( std::vector<double>::size_type i = 0; i < vector.size(); i++ )
new_vector[i] = vector[i] * -1;
@ -102,7 +105,8 @@ negate( std::vector<double> vector )
std::vector<double>
invert( std::vector<double> vector )
{
std::vector<double> new_vector( vector.size() );
std::vector<double> new_vector;
new_vector.reserve( vector.size() );
for( std::vector<double>::size_type i = 0; i < vector.size(); i++ )
new_vector[i] = 1.0 / vector[i];