mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 09:10:00 +00:00
Fixed a microscopic Command TimingsHandler memory leak
This reduces memory usage of an idling server by about 20kb. Definitely worth the time.
This commit is contained in:
parent
1266f8f1aa
commit
de359a2bce
@ -79,11 +79,11 @@ abstract class Command{
|
|||||||
*/
|
*/
|
||||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
|
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
|
||||||
$this->commandData = self::generateDefaultData();
|
$this->commandData = self::generateDefaultData();
|
||||||
$this->name = $this->nextLabel = $this->label = $name;
|
$this->name = $name;
|
||||||
|
$this->setLabel($name);
|
||||||
$this->setDescription($description);
|
$this->setDescription($description);
|
||||||
$this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage;
|
$this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage;
|
||||||
$this->setAliases($aliases);
|
$this->setAliases($aliases);
|
||||||
$this->timings = new TimingsHandler("** Command: " . $name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,6 +208,9 @@ abstract class Command{
|
|||||||
public function setLabel($name){
|
public function setLabel($name){
|
||||||
$this->nextLabel = $name;
|
$this->nextLabel = $name;
|
||||||
if(!$this->isRegistered()){
|
if(!$this->isRegistered()){
|
||||||
|
if($this->timings instanceof TimingsHandler){
|
||||||
|
$this->timings->remove();
|
||||||
|
}
|
||||||
$this->timings = new TimingsHandler("** Command: " . $name);
|
$this->timings = new TimingsHandler("** Command: " . $name);
|
||||||
$this->label = $name;
|
$this->label = $name;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user