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:
Dylan K. Taylor 2017-04-29 18:03:45 +01:00
parent 1266f8f1aa
commit de359a2bce

View File

@ -79,11 +79,11 @@ abstract class Command{
*/
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
$this->commandData = self::generateDefaultData();
$this->name = $this->nextLabel = $this->label = $name;
$this->name = $name;
$this->setLabel($name);
$this->setDescription($description);
$this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage;
$this->setAliases($aliases);
$this->timings = new TimingsHandler("** Command: " . $name);
}
/**
@ -208,6 +208,9 @@ abstract class Command{
public function setLabel($name){
$this->nextLabel = $name;
if(!$this->isRegistered()){
if($this->timings instanceof TimingsHandler){
$this->timings->remove();
}
$this->timings = new TimingsHandler("** Command: " . $name);
$this->label = $name;