FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Reduce BigInteger construction by headius · Pull Request #9292 · jruby/jruby · GitHub

/ jruby Public

Reduce BigInteger construction - #9292

Merged
headius merged 2 commits into
jruby:jruby-10.0from
headius:time_rational_subseconds_tweaks
Mar 28, 2026
Merged

Reduce BigInteger construction#9292
headius merged 2 commits into
jruby:jruby-10.0from
headius:time_rational_subseconds_tweaks

Conversation

headius commented Mar 4, 2026

Copy link
Copy Markdown
Member

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).

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).
headius added this to the JRuby 10.0.5.0 milestone Mar 4, 2026
If numerator == denominator, we don't need to do any of this math
and can avoid constructing any objects.
headius merged commit d6d4709 into jruby:jruby-10.0 Mar 28, 2026
84 checks passed
headius deleted the time_rational_subseconds_tweaks branch March 28, 2026 17:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL