This commit is contained in:
Andrew Nicols 2022-10-06 09:28:57 +08:00
commit 97fe092754
4 changed files with 14 additions and 13 deletions

View file

@ -1,6 +1,14 @@
CHANGELOG CHANGELOG
========= =========
1.11.0
-------------------
* Replace runtime define of a constant to facilitate opcache preloading.
Reported by vedadkajtaz. GitHub #134.
* Resolve minor issue found by the Clang static analyzer in the C
extension.
1.10.1 (2021-04-14) 1.10.1 (2021-04-14)
------------------- -------------------

View file

@ -7,13 +7,6 @@ namespace MaxMind\Db\Reader;
// @codingStandardsIgnoreLine // @codingStandardsIgnoreLine
use RuntimeException; use RuntimeException;
/*
* @ignore
*
* We subtract 1 from the log to protect against precision loss.
*/
\define(__NAMESPACE__ . '\_MM_MAX_INT_BYTES', (int) ((log(\PHP_INT_MAX, 2) - 1) / 8));
class Decoder class Decoder
{ {
/** /**
@ -316,11 +309,11 @@ class Decoder
$integer = 0; $integer = 0;
// PHP integers are signed. _MM_MAX_INT_BYTES is the number of // PHP integers are signed. PHP_INT_SIZE - 1 is the number of
// complete bytes that can be converted to an integer. However, // complete bytes that can be converted to an integer. However,
// we can convert another byte if the leading bit is zero. // we can convert another byte if the leading bit is zero.
$useRealInts = $byteLength <= _MM_MAX_INT_BYTES $useRealInts = $byteLength <= \PHP_INT_SIZE - 1
|| ($byteLength === _MM_MAX_INT_BYTES + 1 && (\ord($bytes[0]) & 0x80) === 0); || ($byteLength === \PHP_INT_SIZE && (\ord($bytes[0]) & 0x80) === 0);
for ($i = 0; $i < $byteLength; ++$i) { for ($i = 0; $i < $byteLength; ++$i) {
$part = \ord($bytes[$i]); $part = \ord($bytes[$i]);
@ -344,7 +337,7 @@ class Decoder
private function sizeFromCtrlByte(int $ctrlByte, int $offset): array private function sizeFromCtrlByte(int $ctrlByte, int $offset): array
{ {
$size = $ctrlByte & 0x1f; $size = $ctrlByte & 0x1F;
if ($size < 29) { if ($size < 29) {
return [$size, $offset]; return [$size, $offset];

View file

@ -24,7 +24,7 @@
"ext-maxminddb": "<1.10.1,>=2.0.0" "ext-maxminddb": "<1.10.1,>=2.0.0"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "*", "friendsofphp/php-cs-fixer": "3.*",
"phpunit/phpunit": ">=8.0.0,<10.0.0", "phpunit/phpunit": ">=8.0.0,<10.0.0",
"php-coveralls/php-coveralls": "^2.1", "php-coveralls/php-coveralls": "^2.1",
"phpunit/phpcov": ">=6.0.0", "phpunit/phpcov": ">=6.0.0",

View file

@ -413,7 +413,7 @@ All rights reserved.</copyright>
<location>maxmind/MaxMind</location> <location>maxmind/MaxMind</location>
<name>MaxMind DB Reader API</name> <name>MaxMind DB Reader API</name>
<description>PHP API for reading MaxMind DB files.</description> <description>PHP API for reading MaxMind DB files.</description>
<version>1.10.1</version> <version>1.11.0</version>
<license>Apache</license> <license>Apache</license>
<licenseversion>2.0</licenseversion> <licenseversion>2.0</licenseversion>
<repository>https://github.com/maxmind/MaxMind-DB-Reader-php/</repository> <repository>https://github.com/maxmind/MaxMind-DB-Reader-php/</repository>