Commit 898b010
committed
Reduce BigInteger construction
The numerator and denominator need to be BigInteger, so request
them as such and reuse those instances. This reduces the number of
BigIntegers constructed to four in the case where they are both
already RubyBignum instances and numerator is less than
denominator, and eight in the worst case where neither of them are
RubyBignum instances and numerator is greater than denominator.
Previously, the best case was six BigInteger (extra from numerator
and denominator being recreated).1 parent 148f885 commit 898b010
1 file changed
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | | - | |
| 139 | + | |
139 | 140 | | |
140 | | - | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
0 commit comments