Sfoglia il codice sorgente

:octocat: some micro optimization

smiley 2 anni fa
parent
commit
af7ba49225
2 ha cambiato i file con 17 aggiunte e 5 eliminazioni
  1. 5 1
      src/Common/ReedSolomonEncoder.php
  2. 12 4
      src/Data/QRMatrix.php

+ 5 - 1
src/Common/ReedSolomonEncoder.php

@@ -100,7 +100,11 @@ final class ReedSolomonEncoder{
 
 
 		foreach($ecBytes as $i => &$val){
 		foreach($ecBytes as $i => &$val){
 			$modIndex = ($i + $count);
 			$modIndex = ($i + $count);
-			$val      = ($modIndex >= 0) ? $modCoefficients[$modIndex] : 0;
+			$val      = 0;
+
+			if($modIndex >= 0){
+				$val = $modCoefficients[$modIndex];
+			}
 		}
 		}
 
 
 		return $ecBytes;
 		return $ecBytes;

+ 12 - 4
src/Data/QRMatrix.php

@@ -749,19 +749,27 @@ class QRMatrix{
 			}
 			}
 
 
 			for($count = 0; $count < $this->moduleCount; $count++){
 			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++){
 				for($col = 0; $col < 2; $col++){
 					$x = ($i - $col);
 					$x = ($i - $col);
 
 
 					// skip functional patterns
 					// skip functional patterns
-					if($this->get($x, $y) !== $this::M_NULL){
+					if($this->matrix[$y][$x] !== $this::M_NULL){
 						continue;
 						continue;
 					}
 					}
 
 
-					$v = $iByte < $byteCount && (($data[$iByte] >> $iBit--) & 1) === 1;
+					$value = 0;
+
+					if($iByte < $byteCount && (($data[$iByte] >> $iBit--) & 1) === 1){
+						$value = $this::IS_DARK;
+					}
 
 
-					$this->set($x, $y, $v, $this::M_DATA);
+					$this->matrix[$y][$x] = ($this::M_DATA | $value);
 
 
 					if($iBit === -1){
 					if($iBit === -1){
 						$iByte++;
 						$iByte++;