Skip to content

Commit

Permalink
Remove grouping parenthesis where not needed
Browse files Browse the repository at this point in the history
The operator precedense of `?:` and assignments are clear.
Removing these parenthesis, since they don't do anything.
  • Loading branch information
lexidor committed May 12, 2021
1 parent adbb893 commit a401f96
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions hack/src/qrcode.hack
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ final class QRCode {
$dark = false;

if ($byteIndex < C\count($data)) {
$dark = (
(($data[$byteIndex] >> $bitIndex) & 1) === 1
);
$dark = (($data[$byteIndex] >> $bitIndex) & 1) ===
1;
}

if (QRUtil::getMask($maskPattern, $row, $col - $c)) {
Expand Down Expand Up @@ -293,8 +292,8 @@ final class QRCode {
continue;
}

$this->modules[$i][6] = ($i % 2 === 0);
$this->modules[6][$i] = ($i % 2 === 0);
$this->modules[$i][6] = $i % 2 === 0;
$this->modules[6][$i] = $i % 2 === 0;
}
}

Expand All @@ -303,7 +302,7 @@ final class QRCode {
$bits = QRUtil::getBCHTypeNumber($this->typeNumber);

for ($i = 0; $i < 18; $i++) {
$mod = (!$test && (($bits >> $i) & 1) === 1);
$mod = !$test && (($bits >> $i) & 1) === 1;
$this->modules[(int)Math\floor($i / 3)][
$i % 3 + $this->moduleCount - 8 - 3
] = $mod;
Expand All @@ -323,7 +322,7 @@ final class QRCode {
$bits = QRUtil::getBCHTypeInfo($data);

for ($i = 0; $i < 15; $i++) {
$mod = (!$test && (($bits >> $i) & 1) === 1);
$mod = !$test && (($bits >> $i) & 1) === 1;

if ($i < 6) {
$this->modules[$i][8] = $mod;
Expand Down Expand Up @@ -441,9 +440,7 @@ final class QRCode {
$ecDataCount = C\count($ecdata[$r]);
for ($i = 0; $i < $ecDataCount; $i++) {
$modIndex = $i + $modPoly->getLength() - C\count($ecdata[$r]);
$ecdata[$r][$i] = ($modIndex >= 0)
? $modPoly->get($modIndex)
: 0;
$ecdata[$r][$i] = $modIndex >= 0 ? $modPoly->get($modIndex) : 0;
}
}

Expand Down Expand Up @@ -870,7 +867,7 @@ final abstract class QRUtil {
}

if ($sameCount > 5) {
$lostPoint += (3 + $sameCount - 5);
$lostPoint += 3 + $sameCount - 5;
}
}
}
Expand Down Expand Up @@ -1032,21 +1029,17 @@ final abstract class QRUtil {
public static function getBCHTypeInfo(int $data): int {
$d = $data << 10;
while (QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G15) >= 0) {
$d ^= (
QR_G15 <<
(QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G15))
);
$d ^= QR_G15 <<
(QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G15));
}
return (($data << 10) | $d) ^ QR_G15_MASK;
}

public static function getBCHTypeNumber(int $data): int {
$d = $data << 12;
while (QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G18) >= 0) {
$d ^= (
QR_G18 <<
(QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G18))
);
$d ^= QR_G18 <<
(QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G18));
}
return ($data << 12) | $d;
}
Expand Down

0 comments on commit a401f96

Please sign in to comment.