Skip to content

Commit

Permalink
moved count() out of for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangibbons committed Oct 17, 2015
1 parent f836686 commit a8eea31
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/phpFITFileAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,9 @@ private function interpolateMissingData(&$missing_keys, &$array)

$min_key = min(array_keys($array));
$max_key = max(array_keys($array));
$count = count($missing_keys);

for ($i=0; $i<count($missing_keys); ++$i) {
for ($i=0; $i<$count; ++$i) {
if ($missing_keys[$i] !== 0) {
// Interpolating outside recorded range is impossible - use edge values instead
if ($missing_keys[$i] > $max_key) {
Expand All @@ -1307,7 +1308,7 @@ private function interpolateMissingData(&$missing_keys, &$array)
$prev_value = current($array);
$next_value = next($array);
}
for ($j=$i+1; $j<count($missing_keys); ++$j) {
for ($j=$i+1; $j<$count; ++$j) {
if ($missing_keys[$j] < key($array)) {
$num_points++;
} else {
Expand Down Expand Up @@ -1671,7 +1672,8 @@ public function partitionData($record_field = '', $thresholds = null, $percentag

foreach ($this->data_mesgs['record'][$record_field] as $value) {
$key = 0;
for ($key; $key<count($thresholds); ++$key) {
$count = count($thresholds);
for ($key; $key<$count; ++$key) {
if ($value < $thresholds[$key]) {
$result[$key]++;
goto loop_end;
Expand All @@ -1685,7 +1687,8 @@ public function partitionData($record_field = '', $thresholds = null, $percentag
$keys = [];

if ($labels_for_keys === true) {
for ($i=0; $i<count($thresholds); ++$i) {
$count = count($thresholds);
for ($i=0; $i<$count; ++$i) {
$keys[] = $thresholds[$i] . (isset($thresholds[$i+1]) ? '-'.($thresholds[$i+1] - 1) : '+');
}
$result = array_combine($keys, $result);
Expand Down

0 comments on commit a8eea31

Please sign in to comment.