mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Server: micro-optimization: avoid unnecessary array_shift()
it's much less expensive to just calculate the modulo of the current tick and 20, and overwrite past entries. The effect is the same. The only difference is that the arrays won't be ordered by time, but that doesn't matter anyway.
This commit is contained in:
parent
93969197f7
commit
ab37df4484
@ -2649,10 +2649,9 @@ class Server{
|
||||
|
||||
TimingsHandler::tick($this->currentTPS <= $this->profilingTickRate);
|
||||
|
||||
array_shift($this->tickAverage);
|
||||
$this->tickAverage[] = $this->currentTPS;
|
||||
array_shift($this->useAverage);
|
||||
$this->useAverage[] = $this->currentUse;
|
||||
$idx = $this->tickCounter % 20;
|
||||
$this->tickAverage[$idx] = $this->currentTPS;
|
||||
$this->useAverage[$idx] = $this->currentUse;
|
||||
|
||||
if(($this->nextTick - $tickTime) < -1){
|
||||
$this->nextTick = $tickTime;
|
||||
|
Loading…
x
Reference in New Issue
Block a user