From 552dbe41ec3b1cb4218f9334148bbce75b030e2c Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Fri, 15 Mar 2019 12:31:30 +0000
Subject: [PATCH] Skip inhibited particles in the naive star pair loops.

---
 src/runner_doiact_stars.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h
index e3a1df7d1a..91a2a763ee 100644
--- a/src/runner_doiact_stars.h
+++ b/src/runner_doiact_stars.h
@@ -204,11 +204,10 @@ void DO_NONSYM_PAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
 
       /* Get a pointer to the jth particle. */
       struct part *restrict pj = &parts_j[pjd];
+
       /* Skip inhibited particles. */
       if (part_is_inhibited(pj, e)) continue;
 
-      const float hj = pj->h;
-
       /* Compute the pairwise distance. */
       const float pjx[3] = {(float)(pj->x[0] - cj->loc[0]),
                             (float)(pj->x[1] - cj->loc[1]),
@@ -222,7 +221,7 @@ void DO_NONSYM_PAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
         error("Particle pj not drifted to current time");
 #endif
 
-      if (r2 < hig2) IACT_STARS(r2, dx, hi, hj, si, pj, a, H);
+      if (r2 < hig2) IACT_STARS(r2, dx, hi, pj->h, si, pj, a, H);
 
     } /* loop over the parts in cj. */
   }   /* loop over the parts in ci. */
@@ -702,6 +701,9 @@ void DOPAIR1_SUBSET_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
       /* Get a pointer to the jth particle. */
       struct part *restrict pj = &parts_j[pjd];
 
+      /* Skip inhibited particles */
+      if (part_is_inhibited(pj, e)) continue;
+
       /* Compute the pairwise distance. */
       float r2 = 0.0f;
       float dx[3];
-- 
GitLab