Skip to content

Commit e8d45cd

Browse files
committed
replace the loop by memset
1 parent 64403ab commit e8d45cd

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

src/gala/potential/potential/src/cpotential.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <math.h>
22
#include <stdlib.h>
3+
#include <string.h>
34
#include "cpotential.h"
45
#include "src/vectorization.h"
56

@@ -217,15 +218,6 @@ void c_gradient(CPotential *p, size_t N, double t, double *qp, double *grad) {
217218

218219
double qp_trans[(p->n_dim) * N];
219220
double tmp_grad[(p->n_dim) * N];
220-
bool need_transform = false;
221-
222-
// Check if any components need transformation
223-
for (size_t i = 0; i < p->n_components; i++) {
224-
if (p->do_shift_rotate[i] != 0) {
225-
need_transform = true;
226-
break;
227-
}
228-
}
229221

230222

231223
// Initialize gradient array
@@ -239,10 +231,9 @@ void c_gradient(CPotential *p, size_t N, double t, double *qp, double *grad) {
239231
(p->gradient)[i](t, (p->parameters)[i], qp, p->n_dim, N, grad, (p->state)[i]);
240232
} else {
241233
// Initialize temporary arrays
242-
for (size_t j = 0; j < p->n_dim * N; j++) {
243-
qp_trans[j] = 0.;
244-
tmp_grad[j] = 0.;
245-
}
234+
memset(qp_trans, 0, sizeof(qp_trans));
235+
memset(tmp_grad, 0, sizeof(tmp_grad));
236+
246237

247238
// Apply shift and rotation to all particles
248239
apply_shift_rotate_N(

0 commit comments

Comments
 (0)