From 9232f4509c4b74718bce2d8f33ba71ca74b38d97 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 4 Jan 2020 14:44:52 +0000 Subject: [PATCH] TimingsHandler: don't bail on redundant attempts to stop non-running timers while it would be nice to bail, providing the environment to allow bailing without breaking stuff requires some complex changes that would reduce performance when timings is not running. Considering the limited usefulness of bailing here anyway, and the fact that it just has to be prevented to not have side effects, it doesn't make a whole lot of sense right now. closes #3261, closes #3269, closes #3254 --- src/pocketmine/timings/TimingsHandler.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/timings/TimingsHandler.php b/src/pocketmine/timings/TimingsHandler.php index 76d5dc5bb..9040bee54 100644 --- a/src/pocketmine/timings/TimingsHandler.php +++ b/src/pocketmine/timings/TimingsHandler.php @@ -180,7 +180,10 @@ class TimingsHandler{ private function internalStopTiming(float $now) : void{ if($this->timingDepth === 0){ - throw new \InvalidStateException("Cannot stop a timer that is not running"); + //TODO: it would be nice to bail here, but since we'd have to track timing depth across resets + //and enable/disable, it would have a performance impact. Therefore, considering the limited + //usefulness of bailing here anyway, we don't currently bother. + return; } if(--$this->timingDepth !== 0 or $this->start == 0){ return;