From 1262edc2b471fe1ad971c0c8378fe551816dc800 Mon Sep 17 00:00:00 2001 From: Florian Weik Date: Sat, 8 Dec 2018 17:26:44 +0100 Subject: [PATCH] core: particle_data: Be less clever. --- src/core/particle_data.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/particle_data.cpp b/src/core/particle_data.cpp index 9dc5d81475d..a7b705499d2 100644 --- a/src/core/particle_data.cpp +++ b/src/core/particle_data.cpp @@ -845,12 +845,12 @@ int remove_particle(int p_id) { namespace { std::pair find_particle(Particle *p, Cell *c) { - const auto n = (c->n > 0) ? std::distance(c->part, p) : -1; - if ((n >= 0) && (n < c->n) && ((c->part + n) == p)) { - return {c, n}; - } else { - return {nullptr, 0}; + for (int i = 0; i < c->n; ++i) { + if ((c->part + i) == p) { + return {c, i}; + } } + return {nullptr, 0}; } std::pair find_particle(Particle *p, CellPList cells) {