From a0d7f1dadbd089487a3641b10352c117b219dd86 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Thu, 10 Nov 2016 21:55:00 +0700 Subject: [PATCH] Optimize GroupsInOrder. GroupsInOrder is an extremely hot function, especially during object picking: before this commit, it was easy to get second plus latencies on picking, and after this commit picking is almost real-time. --- src/generate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generate.cpp b/src/generate.cpp index 80dad8f1..283b58d0 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -59,9 +59,9 @@ bool SolveSpaceUI::GroupsInOrder(hGroup before, hGroup after) { int beforep = -1, afterp = -1; int i; for(i = 0; i < SK.groupOrder.n; i++) { - Group *g = SK.GetGroup(SK.groupOrder.elem[i]); - if(g->h.v == before.v) beforep = i; - if(g->h.v == after.v) afterp = i; + hGroup hg = SK.groupOrder.elem[i]; + if(hg.v == before.v) beforep = i; + if(hg.v == after.v) afterp = i; } if(beforep < 0 || afterp < 0) return false; if(beforep >= afterp) return false;