1
0
mirror of https://github.com/Ne-Lexa/php-zip.git synced 2025-10-19 09:06:17 +02:00

Optimize pack and unpack long fro PHP >= 5.6.3

This commit is contained in:
Ne-Lexa
2016-09-26 18:04:52 +03:00
parent 4c6f27c269
commit ac20d6fbf3
2 changed files with 13 additions and 6 deletions

View File

@@ -18,7 +18,9 @@ class PackUtil
*/
public static function packLongLE($longValue)
{
// TODO test if (version_compare(PHP_VERSION, '5.6.3') >= 0) {return pack("P", $longValue);}
if (version_compare(PHP_VERSION, '5.6.3') >= 0) {
return pack("P", $longValue);
}
$left = 0xffffffff00000000;
$right = 0x00000000ffffffff;
@@ -36,7 +38,9 @@ class PackUtil
*/
public static function unpackLongLE($value)
{
// TODO test if (version_compare(PHP_VERSION, '5.6.3') >= 0){ return current(unpack('P', $value)); }
if (version_compare(PHP_VERSION, '5.6.3') >= 0) {
return current(unpack('P', $value));
}
$unpack = unpack('Va/Vb', $value);
return $unpack['a'] + ($unpack['b'] << 32);
}