use std::move() to avoid extra copy of temporaries
This commit is contained in:
@ -915,20 +915,20 @@ void FixElectrodeConp::update_charges()
|
||||
a = ele_ele_interaction(q_local);
|
||||
r = add_nlocalele(b, a);
|
||||
} else {
|
||||
r = add_nlocalele(r, scale_vector(alpha, y));
|
||||
r = add_nlocalele(r, scale_vector(alpha, std::move(y)));
|
||||
}
|
||||
auto p = constraint_projection(r);
|
||||
double dot_new = dot_nlocalele(r, p);
|
||||
d = add_nlocalele(p, scale_vector(dot_new / dot_old, d));
|
||||
d = add_nlocalele(std::move(p), scale_vector(dot_new / dot_old, d));
|
||||
delta = dot_nlocalele(r, d);
|
||||
dot_old = dot_new;
|
||||
}
|
||||
recompute_potential(b, q_local);
|
||||
recompute_potential(std::move(b), q_local);
|
||||
if (delta > cg_threshold && comm->me == 0) error->warning(FLERR, "CG threshold not reached");
|
||||
} else {
|
||||
error->all(FLERR, "This algorithm is not implemented, yet");
|
||||
}
|
||||
set_charges(q_local);
|
||||
set_charges(std::move(q_local));
|
||||
update_time += MPI_Wtime() - start;
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace Granular_NS;
|
||||
@ -333,11 +334,11 @@ void GranularModel::read_restart(FILE *fp)
|
||||
utils::sfread(FLERR, &num_char, sizeof(int), 1, fp, nullptr, error);
|
||||
MPI_Bcast(&num_char, 1, MPI_INT, 0, world);
|
||||
|
||||
std::string model_name (num_char, ' ');
|
||||
std::string model_name(num_char, ' ');
|
||||
if (comm->me == 0)
|
||||
utils::sfread(FLERR, const_cast<char*>(model_name.data()), sizeof(char),num_char, fp, nullptr, error);
|
||||
MPI_Bcast(const_cast<char*>(model_name.data()), num_char, MPI_CHAR, 0, world);
|
||||
construct_sub_model(model_name, (SubModelType) i);
|
||||
construct_sub_model(std::move(model_name), (SubModelType) i);
|
||||
|
||||
if (comm->me == 0)
|
||||
utils::sfread(FLERR, &num_coeff, sizeof(int), 1, fp, nullptr, error);
|
||||
|
||||
@ -289,7 +289,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic,
|
||||
labelline = line + strlen("ITEM: ATOMS ");
|
||||
}
|
||||
|
||||
Tokenizer tokens(labelline);
|
||||
Tokenizer tokens(std::move(labelline));
|
||||
std::map<std::string, int> labels;
|
||||
nwords = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user