From a911320bab8039498decc8e3783e333ac965e4cd Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 20 Jan 2023 13:26:43 +0100 Subject: [PATCH] perf(PHP): Use static closures for registrations Micro performance optimization as it allows PHP to GC the surrounding class earlier when `$this` isn't bound to the closure. Signed-off-by: Christoph Wurst --- lib/AppInfo/Application.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index cf9803e6f1..b54946725f 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -198,7 +198,7 @@ class Application extends App implements IBootstrap { /** @var IProviderManager $resourceManager */ $resourceManager = $server->get(IProviderManager::class); $resourceManager->registerResourceProvider(ConversationProvider::class); - $server->getEventDispatcher()->addListener(LoadAdditionalScriptsEvent::class, function () { + $server->getEventDispatcher()->addListener(LoadAdditionalScriptsEvent::class, static function () { Util::addScript(self::APP_ID, 'talk-collections'); }); } @@ -212,7 +212,7 @@ class Application extends App implements IBootstrap { } protected function registerNavigationLink(IServerContainer $server): void { - $server->getNavigationManager()->add(function () use ($server) { + $server->getNavigationManager()->add(static function () use ($server) { /** @var Config $config */ $config = $server->get(Config::class); $user = $server->getUserSession()->getUser();