mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-14 10:53:09 +00:00
BigInteger/Engines/PHP: small optimization to EvalBarrett engine
This commit is contained in:
parent
ff595f9951
commit
c7606818e0
@ -270,8 +270,8 @@ abstract class EvalBarrett extends Base
|
|||||||
$_' . $y . ' = array_pad($' . $y . ', $length, 0);
|
$_' . $y . ' = array_pad($' . $y . ', $length, 0);
|
||||||
$carry = 0;
|
$carry = 0;
|
||||||
for ($i = 0, $j = 1; $j < $length; $i+=2, $j+=2) {
|
for ($i = 0, $j = 1; $j < $length; $i+=2, $j+=2) {
|
||||||
$sum = $' . $result . '[$j] * ' . $class::BASE_FULL . ' + $' . $result . '[$i] +
|
$sum = ($' . $result . '[$j] + $_' . $y . '[$j]) * ' . $class::BASE_FULL . '
|
||||||
$_' . $y . '[$j] * ' . $class::BASE_FULL . ' + $_' . $y . '[$i] +
|
+ $' . $result . '[$i] + $_' . $y . '[$i] +
|
||||||
$carry;
|
$carry;
|
||||||
$carry = $sum >= ' . self::float2string($class::MAX_DIGIT2) . ';
|
$carry = $sum >= ' . self::float2string($class::MAX_DIGIT2) . ';
|
||||||
$sum = $carry ? $sum - ' . self::float2string($class::MAX_DIGIT2) . ' : $sum;';
|
$sum = $carry ? $sum - ' . self::float2string($class::MAX_DIGIT2) . ' : $sum;';
|
||||||
@ -316,8 +316,8 @@ abstract class EvalBarrett extends Base
|
|||||||
$carry = 0;
|
$carry = 0;
|
||||||
$size = count($' . $unknown . ');
|
$size = count($' . $unknown . ');
|
||||||
for ($i = 0, $j = 1; $j < $size; $i+= 2, $j+= 2) {
|
for ($i = 0, $j = 1; $j < $size; $i+= 2, $j+= 2) {
|
||||||
$sum = $' . $known . '[$j] * ' . $class::BASE_FULL . ' + $' . $known . '[$i]
|
$sum = ($' . $known . '[$j] - $' . $unknown . '[$j]) * ' . $class::BASE_FULL . ' + $' . $known . '[$i]
|
||||||
- $' . $unknown . '[$j] * ' . $class::BASE_FULL . ' - $' . $unknown . '[$i]
|
- $' . $unknown . '[$i]
|
||||||
- $carry;
|
- $carry;
|
||||||
$carry = $sum < 0;
|
$carry = $sum < 0;
|
||||||
if ($carry) {
|
if ($carry) {
|
||||||
|
Loading…
Reference in New Issue
Block a user