From 0978f41ca2f6bcc6b8b2f665caee772643dff6fb Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 27 Mar 2016 21:54:15 +0200 Subject: [PATCH] Performance fixes --- Math/Optimization/TSP/BruteForce.php | 3 ++- Utils/Barcode/Codebar.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Math/Optimization/TSP/BruteForce.php b/Math/Optimization/TSP/BruteForce.php index e2ee6f89a..ab2047a9b 100644 --- a/Math/Optimization/TSP/BruteForce.php +++ b/Math/Optimization/TSP/BruteForce.php @@ -102,7 +102,8 @@ class BruteForce $population->addTour($tour); } - for ($i = 0; $i < count($cities); $i++) { + $count = count($cities); + for ($i = 0; $i < $count; $i++) { $extended = clone $tour; $extended->addCity($cities[$i]); unset($cities[$i]); diff --git a/Utils/Barcode/Codebar.php b/Utils/Barcode/Codebar.php index d7371b80f..ba66ce80a 100644 --- a/Utils/Barcode/Codebar.php +++ b/Utils/Barcode/Codebar.php @@ -106,9 +106,10 @@ class Codebar extends C128Abstract { $codeString = ''; $length = strlen($this->content); + $lenCodearr = count(self::$CODEARRAY); for ($posX = 1; $posX <= $length; $posX++) { - for ($posY = 0; $posY < count(self::$CODEARRAY); $posY++) { + for ($posY = 0; $posY < $lenCodearr; $posY++) { if (substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY]) $codeString .= self::$CODEARRAY2[$posY] . '1'; }