Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 91d706492d50
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8516d1f76512
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Oct 3, 2016

  1. Replace BigDecimal#!= by BigDecimal#nonzero?.

    The comparison is very expensive, because it first tries to convert the operand (which is a constant Integer 0 here) into a BigDecimal. This in turn is very expensive (because the Integer is first converted into a String, and then, for operating on that String, a java.util.regex.Pattern object is compiled (in line https://github.com/felixvf/jruby/blob/cc79119315496ea019496affe7a6a79ebc1dbed9/core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java#L533)). Using #nonzero? should speed-up the loop considerably.
    Felix von Ferey committed Oct 3, 2016
    1
    Copy the full SHA
    3acd172 View commit details
  2. Merge pull request #4199 from felixvf/fix_bigmath_log_performance

    Replace BigDecimal#!= by BigDecimal#nonzero?.
    kares authored Oct 3, 2016
    Copy the full SHA
    8516d1f View commit details
Showing with 1 addition and 1 deletion.
  1. +1 −1 core/src/main/ruby/jruby/bigdecimal.rb
2 changes: 1 addition & 1 deletion core/src/main/ruby/jruby/bigdecimal.rb
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ def log(x, prec)
series_element = z

i = 1
while series_element != 0 do
while series_element.nonzero? do
sum_exponent = series_sum.exponent
element_exponent = series_element.exponent
remaining_precision = n - (sum_exponent - element_exponent).abs