mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-23 07:51:14 +01:00
Misc performance improvements
This commit is contained in:
parent
ff281761f8
commit
03bd930335
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit 5910fa5e6fcbfd906f9ca5d2e56a77a38adc7ada
|
||||
Subproject commit 62904e7927eab1ccbf445e11197909fb44958d3f
|
@ -113,7 +113,7 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
* @internal
|
||||
* @var int
|
||||
*/
|
||||
const V = 167;
|
||||
const V = 168;
|
||||
/**
|
||||
* Release version.
|
||||
*
|
||||
|
@ -93,7 +93,7 @@ abstract class Message
|
||||
/**
|
||||
* Set my message ID.
|
||||
*/
|
||||
public function setMsgId(int $msgId): self
|
||||
public function setMsgId(?int $msgId): self
|
||||
{
|
||||
$this->msgId = $msgId;
|
||||
|
||||
|
@ -178,9 +178,8 @@ trait ResponseHandler
|
||||
* Handle RPC response.
|
||||
*
|
||||
* @param IncomingMessage $message Incoming message
|
||||
* @param string $requestId Request ID
|
||||
*/
|
||||
private function handleResponse(IncomingMessage $message, ?string $requestId = null): void
|
||||
private function handleResponse(IncomingMessage $message, ?int $requestId = null): void
|
||||
{
|
||||
$requestId ??= $message->getRequestId();
|
||||
$response = $message->read();
|
||||
|
@ -491,6 +491,8 @@ final class TL implements TLInterface
|
||||
throw new Exception(Lang::$current_lang['not_numeric']);
|
||||
}
|
||||
return Tools::packUnsignedInt($object);
|
||||
case 'strlong':
|
||||
return $object;
|
||||
case 'long':
|
||||
if (\is_object($object)) {
|
||||
return \str_pad(\strrev($object->toBytes()), 8, \chr(0));
|
||||
@ -854,8 +856,10 @@ final class TL implements TLInterface
|
||||
return Tools::unpackSignedInt(\stream_get_contents($stream, 4));
|
||||
case '#':
|
||||
return \unpack('V', \stream_get_contents($stream, 4))[1];
|
||||
case 'strlong':
|
||||
return \stream_get_contents($stream, 8);
|
||||
case 'long':
|
||||
return isset($type['strlong']) ? \stream_get_contents($stream, 8) : Tools::unpackSignedLong(\stream_get_contents($stream, 8));
|
||||
return Tools::unpackSignedLong(\stream_get_contents($stream, 8));
|
||||
case 'double':
|
||||
return Tools::unpackDouble(\stream_get_contents($stream, 8));
|
||||
case 'int128':
|
||||
@ -1003,11 +1007,6 @@ final class TL implements TLInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
if (\in_array($arg['name'], ['key_fingerprint', 'server_salt', 'new_server_salt', 'server_public_key_fingerprints', 'ping_id', 'exchange_id'], true)) {
|
||||
$arg['strlong'] = true;
|
||||
} elseif (\in_array($arg['name'], ['peer_tag', 'file_token', 'cdn_key', 'cdn_iv'], true)) {
|
||||
$arg['type'] = 'string';
|
||||
}
|
||||
if ($x['_'] === 'rpc_result' && $arg['name'] === 'result' && isset($type['connection']->outgoing_messages[$x['req_msg_id']])) {
|
||||
/** @var OutgoingMessage */
|
||||
$message = $type['connection']->outgoing_messages[$x['req_msg_id']];
|
||||
@ -1017,8 +1016,6 @@ final class TL implements TLInterface
|
||||
if ($message->getType() && \str_contains($message->getType(), '<')) {
|
||||
$arg['subtype'] = \str_replace(['Vector<', '>'], '', $message->getType());
|
||||
}
|
||||
} elseif ($x['_'] === 'msg_container' && $arg['name'] === 'messages') {
|
||||
$arg['splitSideEffects'] = true;
|
||||
}
|
||||
if (isset($type['connection'])) {
|
||||
$arg['connection'] = $type['connection'];
|
||||
|
@ -25,7 +25,7 @@ namespace danog\MadelineProto\TL;
|
||||
*/
|
||||
trait TLParams
|
||||
{
|
||||
public function parseParams($key, $mtproto = false): void
|
||||
public function parseParams(string $key, bool $mtproto, string $predicate): void
|
||||
{
|
||||
foreach ($this->by_id[$key]['params'] as $kkey => $param) {
|
||||
if (\preg_match('/([^.]+)\\.(\\d+)\\?(.+)/', $param['type'], $matches)) {
|
||||
@ -41,6 +41,19 @@ trait TLParams
|
||||
}
|
||||
$param['type'] = ($mtproto && $param['type'] === 'Message' ? 'MT' : '').$param['type'];
|
||||
$param['type'] = $mtproto && $param['type'] === '%Message' ? '%MTMessage' : $param['type'];
|
||||
|
||||
if (\in_array($param['name'], ['key_fingerprint', 'server_salt', 'new_server_salt', 'ping_id', 'exchange_id'], true)) {
|
||||
$param['type'] = 'strlong';
|
||||
} elseif (\in_array($param['name'], ['peer_tag', 'file_token', 'cdn_key', 'cdn_iv'], true)) {
|
||||
$param['type'] = 'string';
|
||||
} elseif ($param['name'] === 'server_public_key_fingerprints') {
|
||||
$param['subtype'] = 'strlong';
|
||||
}
|
||||
|
||||
if ($predicate === 'msg_container' && $param['name'] === 'messages') {
|
||||
$param['splitSideEffects'] = true;
|
||||
}
|
||||
|
||||
$this->by_id[$key]['params'][$kkey] = $param;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user