:octocat: some micro optimization

This commit is contained in:
smiley
2023-10-17 00:06:39 +02:00
parent d2dd077f14
commit af7ba49225
2 changed files with 17 additions and 5 deletions
+5 -1
View File
@@ -100,7 +100,11 @@ final class ReedSolomonEncoder{
foreach($ecBytes as $i => &$val){
$modIndex = ($i + $count);
$val = ($modIndex >= 0) ? $modCoefficients[$modIndex] : 0;
$val = 0;
if($modIndex >= 0){
$val = $modCoefficients[$modIndex];
}
}
return $ecBytes;
+12 -4
View File
@@ -749,19 +749,27 @@ class QRMatrix{
}
for($count = 0; $count < $this->moduleCount; $count++){
$y = ($direction) ? ($this->moduleCount - 1 - $count) : $count;
$y = $count;
if($direction){
$y = ($this->moduleCount - 1 - $count);
}
for($col = 0; $col < 2; $col++){
$x = ($i - $col);
// skip functional patterns
if($this->get($x, $y) !== $this::M_NULL){
if($this->matrix[$y][$x] !== $this::M_NULL){
continue;
}
$v = $iByte < $byteCount && (($data[$iByte] >> $iBit--) & 1) === 1;
$value = 0;
$this->set($x, $y, $v, $this::M_DATA);
if($iByte < $byteCount && (($data[$iByte] >> $iBit--) & 1) === 1){
$value = $this::IS_DARK;
}
$this->matrix[$y][$x] = ($this::M_DATA | $value);
if($iBit === -1){
$iByte++;