From cf71e5b9c7ec69d6842891593cf250a9fa2f30e5 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Sat, 17 Nov 2018 16:45:29 +0100
Subject: [PATCH] Re-arrange the debugginc code to be more efficient.

---
 src/cell.c   | 7 +++----
 src/runner.c | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index 33fad78ccc..1b62d81b99 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -3774,13 +3774,12 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) {
 
     /* Update the gpart->spart links (shift by 1) */
     for (int i = 0; i < n_copy; ++i) {
-      if (c->stars.parts[i + 1].gpart != NULL) {
-        c->stars.parts[i + 1].gpart->id_or_neg_offset--;
-      } else {
 #ifdef SWIFT_DEBUG_CHECKS
+      if (c->stars.parts[i + 1].gpart == NULL) {
         error("Incorrectly linked spart!");
-#endif
       }
+#endif
+      c->stars.parts[i + 1].gpart->id_or_neg_offset--;
     }
   }
 
diff --git a/src/runner.c b/src/runner.c
index 6edb69d06e..ab74d8e19c 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -529,8 +529,8 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
           /* Create a fresh (empty) spart */
           struct spart *sp = cell_add_spart(e, c);
 
-	  /* Did we run out of free spart slots? */
-	  if (sp == NULL) continue;
+          /* Did we run out of free spart slots? */
+          if (sp == NULL) continue;
 
           /* Destroy the gas particle and get it's gpart friend */
           struct gpart *gp = cell_convert_part_to_gpart(e, c, p, xp);
-- 
GitLab