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: dd58df359344
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7402c0709d32
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jan 15, 2015

  1. Copy the full SHA
    f8931b8 View commit details

Commits on Jan 16, 2015

  1. Merge pull request #2464 from Who828/fix_2360

    Improved String#to_i performance for base <= 10
    headius committed Jan 16, 2015
    Copy the full SHA
    7402c07 View commit details
Showing with 14 additions and 2 deletions.
  1. +14 −2 core/src/main/java/org/jruby/util/ConvertBytes.java
16 changes: 14 additions & 2 deletions core/src/main/java/org/jruby/util/ConvertBytes.java
Original file line number Diff line number Diff line change
@@ -619,10 +619,13 @@ public RubyInteger byteListToInum() {
return runtime.newFixnum(0);
}

len *= (end-str);
if (base <= 10) {
len *= (trailingLength());
} else {
len *= (end-str);
}

//System.err.println(" main/len=" + len);

if(len < Long.SIZE-1) {
int[] endPlace = new int[]{str};
long val = stringToLong(str, endPlace, base);
@@ -653,6 +656,15 @@ public RubyInteger byteListToInum() {
return bigParse(len, sign);
}

private int trailingLength() {
int newLen = 0;
for (int i=str; i < end; i++) {
if (Character.isDigit(data[i])) newLen++;
else return newLen;
}
return newLen;
}

private RubyInteger bigParse(int len, boolean sign) {
if(badcheck && str < end && data[str] == '_') {
invalidString("Integer");