Skip to content

Commit

Permalink
Avoid function call on for loop condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ocubom committed Jan 11, 2015
1 parent 3d9f0a4 commit 281eccb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ protected static function convertToBase10($number, $base)
return empty($number) ? '0' : $number; // No conversion needed
}

$len = strlen($number);

$value = 0;
for ($i = 0; $i < strlen($number); $i++) {
for ($i = 0; $i < $len; $i++) {
$digit = base_convert($number[$i], $base, 10);
$value = bcadd(bcmul($value, $base), $digit);
}
Expand Down

0 comments on commit 281eccb

Please sign in to comment.