Remove redundant function calls in for loops
This commit is contained in:
parent
d383bc356c
commit
f246ad731d
|
@ -1602,7 +1602,8 @@ class Financial
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
$rate = array_shift($aArgs);
|
$rate = array_shift($aArgs);
|
||||||
for ($i = 1; $i <= count($aArgs); ++$i) {
|
$countArgs = count($aArgs);
|
||||||
|
for ($i = 1; $i <= $countArgs; ++$i) {
|
||||||
// Is it a numeric value?
|
// Is it a numeric value?
|
||||||
if (is_numeric($aArgs[$i - 1])) {
|
if (is_numeric($aArgs[$i - 1])) {
|
||||||
$returnValue += $aArgs[$i - 1] / pow(1 + $rate, $i);
|
$returnValue += $aArgs[$i - 1] / pow(1 + $rate, $i);
|
||||||
|
|
|
@ -2700,7 +2700,8 @@ class Statistical
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($cumulative) {
|
if ($cumulative) {
|
||||||
$summer = 0;
|
$summer = 0;
|
||||||
for ($i = 0; $i <= floor($value); ++$i) {
|
$floor = floor($value);
|
||||||
|
for ($i = 0; $i <= $floor; ++$i) {
|
||||||
$summer += pow($mean, $i) / MathTrig::FACT($i);
|
$summer += pow($mean, $i) / MathTrig::FACT($i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,8 @@ class JpGraph implements IRenderer
|
||||||
|
|
||||||
$dataValuesPlot = [];
|
$dataValuesPlot = [];
|
||||||
// Flatten the plot arrays to a single dimensional array to work with jpgraph
|
// Flatten the plot arrays to a single dimensional array to work with jpgraph
|
||||||
for ($j = 0; $j < count($dataValues[0]); ++$j) {
|
$jMax = count($dataValues[0]);
|
||||||
|
for ($j = 0; $j < $jMax; ++$j) {
|
||||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||||
$dataValuesPlot[] = $dataValues[$i][$j];
|
$dataValuesPlot[] = $dataValues[$i][$j];
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,8 @@ class Slk extends BaseReader
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
$styleSettings = substr($rowDatum, 1);
|
$styleSettings = substr($rowDatum, 1);
|
||||||
for ($i = 0; $i < strlen($styleSettings); ++$i) {
|
$iMax = strlen($styleSettings);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
switch ($styleSettings[$i]) {
|
switch ($styleSettings[$i]) {
|
||||||
case 'I':
|
case 'I':
|
||||||
$formatArray['font']['italic'] = true;
|
$formatArray['font']['italic'] = true;
|
||||||
|
@ -386,7 +387,8 @@ class Slk extends BaseReader
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
$styleSettings = substr($rowDatum, 1);
|
$styleSettings = substr($rowDatum, 1);
|
||||||
for ($i = 0; $i < strlen($styleSettings); ++$i) {
|
$iMax = strlen($styleSettings);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
switch ($styleSettings[$i]) {
|
switch ($styleSettings[$i]) {
|
||||||
case 'I':
|
case 'I':
|
||||||
$styleData['font']['italic'] = true;
|
$styleData['font']['italic'] = true;
|
||||||
|
|
|
@ -1889,7 +1889,8 @@ class Xls extends BaseReader
|
||||||
{
|
{
|
||||||
$pwarray = str_repeat("\0", 64);
|
$pwarray = str_repeat("\0", 64);
|
||||||
|
|
||||||
for ($i = 0; $i < strlen($password); ++$i) {
|
$iMax = strlen($password);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
$o = ord(substr($password, $i, 1));
|
$o = ord(substr($password, $i, 1));
|
||||||
$pwarray[2 * $i] = chr($o & 0xff);
|
$pwarray[2 * $i] = chr($o & 0xff);
|
||||||
$pwarray[2 * $i + 1] = chr(($o >> 8) & 0xff);
|
$pwarray[2 * $i + 1] = chr(($o >> 8) & 0xff);
|
||||||
|
@ -3087,7 +3088,8 @@ class Xls extends BaseReader
|
||||||
// 1st fragment compressed
|
// 1st fragment compressed
|
||||||
// this fragment uncompressed
|
// this fragment uncompressed
|
||||||
$newstr = '';
|
$newstr = '';
|
||||||
for ($j = 0; $j < strlen($retstr); ++$j) {
|
$jMax = strlen($retstr);
|
||||||
|
for ($j = 0; $j < $jMax; ++$j) {
|
||||||
$newstr .= $retstr[$j] . chr(0);
|
$newstr .= $retstr[$j] . chr(0);
|
||||||
}
|
}
|
||||||
$retstr = $newstr;
|
$retstr = $newstr;
|
||||||
|
|
|
@ -88,7 +88,8 @@ class File
|
||||||
if ($returnValue == '' || ($returnValue === null)) {
|
if ($returnValue == '' || ($returnValue === null)) {
|
||||||
$pathArray = explode('/', $pFilename);
|
$pathArray = explode('/', $pFilename);
|
||||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
$iMax = count($pathArray);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
if ($pathArray[$i] == '..' && $i > 0) {
|
if ($pathArray[$i] == '..' && $i > 0) {
|
||||||
unset($pathArray[$i], $pathArray[$i - 1]);
|
unset($pathArray[$i], $pathArray[$i - 1]);
|
||||||
|
|
||||||
|
|
|
@ -607,7 +607,8 @@ class EigenvalueDecomposition
|
||||||
$this->H[$k + 1][$j] = $this->H[$k + 1][$j] - $p * $y;
|
$this->H[$k + 1][$j] = $this->H[$k + 1][$j] - $p * $y;
|
||||||
}
|
}
|
||||||
// Column modification
|
// Column modification
|
||||||
for ($i = 0; $i <= min($n, $k + 3); ++$i) {
|
$iMax = min($n, $k + 3);
|
||||||
|
for ($i = 0; $i <= $iMax; ++$i) {
|
||||||
$p = $x * $this->H[$i][$k] + $y * $this->H[$i][$k + 1];
|
$p = $x * $this->H[$i][$k] + $y * $this->H[$i][$k + 1];
|
||||||
if ($notlast) {
|
if ($notlast) {
|
||||||
$p = $p + $z * $this->H[$i][$k + 2];
|
$p = $p + $z * $this->H[$i][$k + 2];
|
||||||
|
@ -762,7 +763,8 @@ class EigenvalueDecomposition
|
||||||
for ($j = $nn - 1; $j >= $low; --$j) {
|
for ($j = $nn - 1; $j >= $low; --$j) {
|
||||||
for ($i = $low; $i <= $high; ++$i) {
|
for ($i = $low; $i <= $high; ++$i) {
|
||||||
$z = 0.0;
|
$z = 0.0;
|
||||||
for ($k = $low; $k <= min($j, $high); ++$k) {
|
$kMax = min($j, $high);
|
||||||
|
for ($k = $low; $k <= $kMax; ++$k) {
|
||||||
$z = $z + $this->V[$i][$k] * $this->H[$k][$j];
|
$z = $z + $this->V[$i][$k] * $this->H[$k][$j];
|
||||||
}
|
}
|
||||||
$this->V[$i][$j] = $z;
|
$this->V[$i][$j] = $z;
|
||||||
|
|
|
@ -81,7 +81,8 @@ class SingularValueDecomposition
|
||||||
|
|
||||||
// Reduce A to bidiagonal form, storing the diagonal elements
|
// Reduce A to bidiagonal form, storing the diagonal elements
|
||||||
// in s and the super-diagonal elements in e.
|
// in s and the super-diagonal elements in e.
|
||||||
for ($k = 0; $k < max($nct, $nrt); ++$k) {
|
$kMax = max($nct, $nrt);
|
||||||
|
for ($k = 0; $k < $kMax; ++$k) {
|
||||||
if ($k < $nct) {
|
if ($k < $nct) {
|
||||||
// Compute the transformation for the k-th column and
|
// Compute the transformation for the k-th column and
|
||||||
// place the k-th diagonal in s[$k].
|
// place the k-th diagonal in s[$k].
|
||||||
|
@ -518,7 +519,8 @@ class SingularValueDecomposition
|
||||||
$eps = pow(2.0, -52.0);
|
$eps = pow(2.0, -52.0);
|
||||||
$tol = max($this->m, $this->n) * $this->s[0] * $eps;
|
$tol = max($this->m, $this->n) * $this->s[0] * $eps;
|
||||||
$r = 0;
|
$r = 0;
|
||||||
for ($i = 0; $i < count($this->s); ++$i) {
|
$iMax = count($this->s);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
if ($this->s[$i] > $tol) {
|
if ($this->s[$i] > $tol) {
|
||||||
++$r;
|
++$r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,7 +479,8 @@ class OLE
|
||||||
public static function ascToUcs($ascii)
|
public static function ascToUcs($ascii)
|
||||||
{
|
{
|
||||||
$rawname = '';
|
$rawname = '';
|
||||||
for ($i = 0; $i < strlen($ascii); ++$i) {
|
$iMax = strlen($ascii);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
$rawname .= $ascii[$i]
|
$rawname .= $ascii[$i]
|
||||||
. "\x00";
|
. "\x00";
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,7 +543,8 @@ class Workbook extends BIFFwriter
|
||||||
foreach ($namedRanges as $namedRange) {
|
foreach ($namedRanges as $namedRange) {
|
||||||
// Create absolute coordinate
|
// Create absolute coordinate
|
||||||
$range = Coordinate::splitRange($namedRange->getRange());
|
$range = Coordinate::splitRange($namedRange->getRange());
|
||||||
for ($i = 0; $i < count($range); ++$i) {
|
$iMax = count($range);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
$range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . Coordinate::absoluteCoordinate($range[$i][0]);
|
$range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . Coordinate::absoluteCoordinate($range[$i][0]);
|
||||||
if (isset($range[$i][1])) {
|
if (isset($range[$i][1])) {
|
||||||
$range[$i][1] = Coordinate::absoluteCoordinate($range[$i][1]);
|
$range[$i][1] = Coordinate::absoluteCoordinate($range[$i][1]);
|
||||||
|
|
|
@ -315,7 +315,8 @@ class Workbook extends WriterPart
|
||||||
|
|
||||||
// Create absolute coordinate and write as raw text
|
// Create absolute coordinate and write as raw text
|
||||||
$range = Coordinate::splitRange($pNamedRange->getRange());
|
$range = Coordinate::splitRange($pNamedRange->getRange());
|
||||||
for ($i = 0; $i < count($range); ++$i) {
|
$iMax = count($range);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
$range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . Coordinate::absoluteReference($range[$i][0]);
|
$range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . Coordinate::absoluteReference($range[$i][0]);
|
||||||
if (isset($range[$i][1])) {
|
if (isset($range[$i][1])) {
|
||||||
$range[$i][1] = Coordinate::absoluteReference($range[$i][1]);
|
$range[$i][1] = Coordinate::absoluteReference($range[$i][1]);
|
||||||
|
|
Loading…
Reference in New Issue