Commit 61c9c3dd authored by Robert Griesemer's avatar Robert Griesemer

math/big: implement fast path in Float.SetRat if argument is integer

Change-Id: Ib82500e198b86e9fade278c7eea7a4b0c6b0b2e1
Reviewed-on: https://go-review.googlesource.com/4921Reviewed-by: default avatarRob Pike <r@golang.org>
parent 52dadc1f
......@@ -582,7 +582,9 @@ func (z *Float) SetInt(x *Int) *Float {
// If z's precision is 0, it is changed to the largest of a.BitLen(),
// b.BitLen(), or 64; with x = a/b.
func (z *Float) SetRat(x *Rat) *Float {
// TODO(gri) can be more efficient if x is an integer
if x.IsInt() {
return z.SetInt(x.Num())
}
var a, b Float
a.SetInt(x.Num())
b.SetInt(x.Denom())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment