From 580b6a3b2c8e6b5d7ad4bec5a356fd1064233892 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 6 Sep 2019 08:56:05 -0700 Subject: [PATCH] small optimization: check before lock --- libraries/entities/src/EntityTree.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index dca3ac595a..6c12c6d019 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2246,8 +2246,8 @@ void EntityTree::preUpdate() { void EntityTree::update(bool simulate) { PROFILE_RANGE(simulation_physics, "UpdateTree"); PerformanceTimer perfTimer("updateTree"); - withWriteLock([&] { - if (simulate && _simulation) { + if (simulate && _simulation) { + withWriteLock([&] { _simulation->updateEntities(); { PROFILE_RANGE(simulation_physics, "Deletes"); @@ -2265,8 +2265,8 @@ void EntityTree::update(bool simulate) { deleteEntities(idsToDelete, true); } } - } - }); + }); + } } quint64 EntityTree::getAdjustedConsiderSince(quint64 sinceTime) {