1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 19:24:42 +01:00

Performance improvements

This commit is contained in:
Daniil Gentili 2023-08-27 10:46:42 +02:00
parent c60fd81e68
commit 11bf2138ba
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 11 additions and 9 deletions

2
docs

@ -1 +1 @@
Subproject commit 2252db95c03cbc54588a9368fa96d9cb910cb33d
Subproject commit f855706e1b65ce6b4c5a6babed5928a138d10f56

View File

@ -164,7 +164,7 @@ abstract class EventHandler extends AbstractAPI
$method_name = \lcfirst(\substr($method, 2));
if (($constructor = $constructors->findByPredicate($method_name)) && $constructor['type'] === 'Update') {
$methods[$method_name] = [
function (array $update) use ($basic_handler, $closure): void {
static function (array $update) use ($basic_handler, $closure): void {
EventLoop::queue($basic_handler, $update, $closure);
}
];
@ -179,7 +179,7 @@ abstract class EventHandler extends AbstractAPI
}
$periodic = $periodic[0]->newInstance();
$this->periodicLoops[$method] = new PeriodicLoop(
function (PeriodicLoop $loop) use ($closure): bool {
static function (PeriodicLoop $loop) use ($closure): bool {
return $closure($loop) ?? false;
},
$method,
@ -208,10 +208,12 @@ abstract class EventHandler extends AbstractAPI
if (!$this instanceof SimpleEventHandler) {
throw new AssertionError("Please extend SimpleEventHandler to use filters!");
}
$handlers []= function (Update $update) use ($closure, $filter): void {
if ($filter->apply($update)) {
EventLoop::queue($closure, $update);
}
$handlers []= static function (Update $update) use ($closure, $filter): void {
EventLoop::queue(static function () use ($closure, $filter, $update) {
if ($filter->apply($update)) {
$closure($update);
}
});
};
}
if ($this instanceof SimpleEventHandler) {
@ -435,7 +437,7 @@ abstract class EventHandler extends AbstractAPI
continue;
}
\spl_autoload_register(function (string $class) use ($p): void {
\spl_autoload_register(static function (string $class) use ($p): void {
if (!\str_starts_with($class, 'MadelinePlugin\\')) {
return;
}

View File

@ -1,6 +1,6 @@
{
"require": {
"psalm/phar": "^5",
"vimeo/psalm": "dev-master",
"ennexa/amp-update-cache": "dev-master",
"phpunit/phpunit": "^9",
"amphp/php-cs-fixer-config": "v2.x-dev",