From d9bc354f4ffac7b81733f0dae3ff1249a91a0b7a Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Thu, 23 Apr 2015 18:15:41 +0800 Subject: [PATCH] Removed redundant &0xFF According to a local test in PHP 5.6.3, chr(256) returns a null byte. This shows that chr() used in DataPacket.php returns the integer representation of the least significant byte only, so `& 0xFF` is not necessary. --- src/shoghicp/FastTransfer/StrangePacket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shoghicp/FastTransfer/StrangePacket.php b/src/shoghicp/FastTransfer/StrangePacket.php index 0674b4c..0ff5c39 100644 --- a/src/shoghicp/FastTransfer/StrangePacket.php +++ b/src/shoghicp/FastTransfer/StrangePacket.php @@ -32,7 +32,7 @@ protected function putAddress($addr, $port, $version = 4){ $this->putByte($version); if($version === 4){ foreach(explode(".", $addr) as $b){ - $this->putByte((~((int) $b)) & 0xff); + $this->putByte(~((int) $b)); } $this->putShort($port); }else{ @@ -49,4 +49,4 @@ public function encode(){ $this->putAddress($this->address, $this->port); } -} \ No newline at end of file +}