mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 20:54:42 +01:00
Performance improvements
This commit is contained in:
parent
c60fd81e68
commit
11bf2138ba
2
docs
2
docs
@ -1 +1 @@
|
|||||||
Subproject commit 2252db95c03cbc54588a9368fa96d9cb910cb33d
|
Subproject commit f855706e1b65ce6b4c5a6babed5928a138d10f56
|
@ -164,7 +164,7 @@ abstract class EventHandler extends AbstractAPI
|
|||||||
$method_name = \lcfirst(\substr($method, 2));
|
$method_name = \lcfirst(\substr($method, 2));
|
||||||
if (($constructor = $constructors->findByPredicate($method_name)) && $constructor['type'] === 'Update') {
|
if (($constructor = $constructors->findByPredicate($method_name)) && $constructor['type'] === 'Update') {
|
||||||
$methods[$method_name] = [
|
$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);
|
EventLoop::queue($basic_handler, $update, $closure);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -179,7 +179,7 @@ abstract class EventHandler extends AbstractAPI
|
|||||||
}
|
}
|
||||||
$periodic = $periodic[0]->newInstance();
|
$periodic = $periodic[0]->newInstance();
|
||||||
$this->periodicLoops[$method] = new PeriodicLoop(
|
$this->periodicLoops[$method] = new PeriodicLoop(
|
||||||
function (PeriodicLoop $loop) use ($closure): bool {
|
static function (PeriodicLoop $loop) use ($closure): bool {
|
||||||
return $closure($loop) ?? false;
|
return $closure($loop) ?? false;
|
||||||
},
|
},
|
||||||
$method,
|
$method,
|
||||||
@ -208,10 +208,12 @@ abstract class EventHandler extends AbstractAPI
|
|||||||
if (!$this instanceof SimpleEventHandler) {
|
if (!$this instanceof SimpleEventHandler) {
|
||||||
throw new AssertionError("Please extend SimpleEventHandler to use filters!");
|
throw new AssertionError("Please extend SimpleEventHandler to use filters!");
|
||||||
}
|
}
|
||||||
$handlers []= function (Update $update) use ($closure, $filter): void {
|
$handlers []= static function (Update $update) use ($closure, $filter): void {
|
||||||
if ($filter->apply($update)) {
|
EventLoop::queue(static function () use ($closure, $filter, $update) {
|
||||||
EventLoop::queue($closure, $update);
|
if ($filter->apply($update)) {
|
||||||
}
|
$closure($update);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if ($this instanceof SimpleEventHandler) {
|
if ($this instanceof SimpleEventHandler) {
|
||||||
@ -435,7 +437,7 @@ abstract class EventHandler extends AbstractAPI
|
|||||||
continue;
|
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\\')) {
|
if (!\str_starts_with($class, 'MadelinePlugin\\')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"psalm/phar": "^5",
|
"vimeo/psalm": "dev-master",
|
||||||
"ennexa/amp-update-cache": "dev-master",
|
"ennexa/amp-update-cache": "dev-master",
|
||||||
"phpunit/phpunit": "^9",
|
"phpunit/phpunit": "^9",
|
||||||
"amphp/php-cs-fixer-config": "v2.x-dev",
|
"amphp/php-cs-fixer-config": "v2.x-dev",
|
||||||
|
Loading…
Reference in New Issue
Block a user