Remove unnecessary conversions in BigNumberConverter

Using the baseConvert method from BigNumber uses two consecutive convert operations:
  - convertToBase10
  - convertFromBase10

In BigNumberConverters context, we can directly call each specific method to avoid
the conversion overhead.
This commit is contained in:
Thibaud Fabre
2015-08-13 17:44:02 +02:00
parent 8cf0113302
commit 89d91a97eb
+2 -2
View File
@@ -23,7 +23,7 @@ class BigNumberConverter implements NumberConverterInterface
*/
public function fromHex($hex)
{
$number = \Moontoast\Math\BigNumber::baseConvert($hex, 16, 10);
$number = \Moontoast\Math\BigNumber::convertToBase10($hex, 16);
return new \Moontoast\Math\BigNumber($number);
}
@@ -34,6 +34,6 @@ class BigNumberConverter implements NumberConverterInterface
$integer = new \Moontoast\Math\BigNumber($integer);
}
return \Moontoast\Math\BigNumber::baseConvert($integer, 10, 16);
return \Moontoast\Math\BigNumber::convertFromBase10($integer, 16);
}
}