From b9062e6a07ece3faa79bb16d141f14594c48a48e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 10 Apr 2018 07:59:48 +0200 Subject: [PATCH] faster celldistance on smallbounded --- cell.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cell.cpp b/cell.cpp index 9ca25b45..20ffbe7a 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1361,6 +1361,8 @@ int heptdistance(cell *c1, cell *c2) { else return heptdistance(c1->master, c2->master); } +map, int> saved_distances; + int celldistance(cell *c1, cell *c2) { int d = 0; @@ -1371,9 +1373,26 @@ int celldistance(cell *c1, cell *c2) { } if(sphere || quotient == 1 || gp::on) { + + if(saved_distances.count(make_pair(c1,c2))) + return saved_distances[make_pair(c1,c2)]; + + celllister cl(c1, 64, 1000, c2); + for(int i=0; i