From 0bda8d2e11c032f291abd0f982831cc876d8c1f9 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Mon, 11 Mar 2019 09:35:09 +0000
Subject: [PATCH] Only trigger an emergency sort of the stars after star
 formation if we are running with feedback (and hence need sorted stars).

---
 src/runner.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/runner.c b/src/runner.c
index 83e489caba..dfbb9e2149 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -573,6 +573,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
   struct part *restrict parts = c->hydro.parts;
   struct xpart *restrict xparts = c->hydro.xparts;
   const int with_cosmology = (e->policy & engine_policy_cosmology);
+  const int with_feedback = (e->policy & engine_policy_feedback);
   const struct hydro_props *restrict hydro_props = e->hydro_properties;
   const struct unit_system *restrict us = e->internal_units;
   struct cooling_function_data *restrict cooling = e->cooling_func;
@@ -648,7 +649,8 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
 
   /* If we formed any stars, the star sorts are now invalid. We need to
    * re-compute them. */
-  if ((c == c->hydro.super) && (current_stars_count != c->stars.count)) {
+  if (with_feedback && (c == c->hydro.super) &&
+      (current_stars_count != c->stars.count)) {
     cell_clear_stars_sort_flags(c, /*is_super=*/1);
     runner_do_stars_sort(r, c, 0x1FFF, /*cleanup=*/0, /*timer=*/0);
   }
-- 
GitLab