BigInteger: code cleanup

generateCustomReduction() is called by slidingWindow() and
createRecurringModuloFunction(). i suspect this code was an early
attempt to implement what'd later become createRecurringModuloFunction()
This commit is contained in:
terrafrost 2021-08-14 15:32:21 -05:00
parent 291eec0ce5
commit e5e21c114f
6 changed files with 3 additions and 22 deletions

View File

@ -514,8 +514,6 @@ class BCMath extends Engine
*/
protected function normalize(BCMath $result)
{
unset($result->reduce);
$result->precision = $this->precision;
$result->bitmask = $this->bitmask;

View File

@ -59,11 +59,6 @@ abstract class EvalBarrett extends Base
*/
protected static function generateCustomReduction(BCMath $m, $class)
{
if (isset($n->reduce)) {
self::$custom_reduction = $n->reduce;
return $n->reduce;
}
$m_length = strlen($m);
if ($m_length < 5) {

View File

@ -1081,20 +1081,18 @@ abstract class Engine
static::$modexpEngine;
if (method_exists($fqengine, 'generateCustomReduction')) {
$func = $fqengine::generateCustomReduction($this, static::class);
$this->reduce = eval('return function(' . static::class . ' $x) use ($func, $class) {
return eval('return function(' . static::class . ' $x) use ($func, $class) {
$r = new $class();
$r->value = $func($x->value);
return $r;
};');
return clone $this->reduce;
}
$n = $this->value;
$this->reduce = eval('return function(' . static::class . ' $x) use ($n, $fqengine, $class) {
return eval('return function(' . static::class . ' $x) use ($n, $fqengine, $class) {
$r = new $class();
$r->value = $fqengine::reduce($x->value, $n, $class);
return $r;
};');
return clone $this->reduce;
}
/**

View File

@ -512,8 +512,6 @@ class GMP extends Engine
*/
protected function normalize(GMP $result)
{
unset($result->reduce);
$result->precision = $this->precision;
$result->bitmask = $this->bitmask;
@ -683,10 +681,9 @@ class GMP extends Engine
public function createRecurringModuloFunction()
{
$temp = $this->value;
$this->reduce = function(GMP $x) use ($temp) {
return function(GMP $x) use ($temp) {
return new GMP($x->value % $temp);
};
return $this->reduce;
}
/**

View File

@ -731,8 +731,6 @@ abstract class PHP extends Engine
*/
protected function normalize(PHP $result)
{
unset($result->reduce);
$result->precision = $this->precision;
$result->bitmask = $this->bitmask;

View File

@ -60,11 +60,6 @@ abstract class EvalBarrett extends Base
*/
protected static function generateCustomReduction(PHP $m, $class)
{
if (isset($n->reduce)) {
self::$custom_reduction = $n->reduce;
return $n->reduce;
}
$m_length = count($m->value);
if ($m_length < 5) {