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: cc62cf983d8f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7f2f4d0759a0
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 19, 2015

  1. Copy the full SHA
    a823be5 View commit details
  2. More tweaks for tr.

    headius committed Mar 19, 2015
    Copy the full SHA
    6fa1e10 View commit details

Commits on Mar 20, 2015

  1. Copy the full SHA
    a8a36a7 View commit details
  2. Copy the full SHA
    7f2f4d0 View commit details
20 changes: 11 additions & 9 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -4437,6 +4437,7 @@ public IRubyObject count19(ThreadContext context) {
throw context.runtime.newArgumentError("wrong number of arguments");
}

// MRI: rb_str_count, first half
@JRubyMethod(name = "count")
public IRubyObject count19(ThreadContext context, IRubyObject arg) {
Ruby runtime = context.runtime;
@@ -4448,7 +4449,7 @@ public IRubyObject count19(ThreadContext context, IRubyObject arg) {

if (otherBL.length() == 1 && enc.isAsciiCompatible() &&
enc.isReverseMatchAllowed(otherBL.unsafeBytes(), otherBL.begin(), otherBL.begin() + otherBL.getRealSize()) &&
scanForCodeRange() != CR_BROKEN) {
!isCodeRangeBroken()) {
int n = 0;
int[] len_p = {0};
int c = EncodingUtils.encCodepointLength(runtime, otherBL.unsafeBytes(), otherBL.begin(), otherBL.begin() + otherBL.getRealSize(), len_p, enc);
@@ -4468,6 +4469,7 @@ public IRubyObject count19(ThreadContext context, IRubyObject arg) {
return runtime.newFixnum(StringSupport.countCommon19(value, runtime, table, tables, enc));
}

// MRI: rb_str_count for arity > 1, first half
@JRubyMethod(name = "count", required = 1, rest = true)
public IRubyObject count19(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
@@ -4559,18 +4561,19 @@ public IRubyObject delete_bang19(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
if (value.getRealSize() == 0) return runtime.getNil();

RubyString otherStr = args[0].convertToString();
Encoding enc = checkEncoding(otherStr);
boolean[]squeeze = new boolean[StringSupport.TRANS_SIZE + 1];
StringSupport.TrTables tables = StringSupport.trSetupTable(otherStr.value, runtime, squeeze, null, true, enc);
for (int i=1; i<args.length; i++) {
RubyString otherStr;
Encoding enc = null;
boolean[] squeeze = new boolean[StringSupport.TRANS_SIZE + 1];
StringSupport.TrTables tables = null;

for (int i=0; i<args.length; i++) {
otherStr = args[i].convertToString();
enc = checkEncoding(otherStr);
tables = StringSupport.trSetupTable(otherStr.value, runtime, squeeze, tables, false, enc);
tables = StringSupport.trSetupTable(otherStr.value, runtime, squeeze, tables, i == 0, enc);
}

if (StringSupport.delete_bangCommon19(this, runtime, squeeze, tables, enc) == null) {
return runtime.getNil();
return context.nil;
}

return this;
@@ -4930,7 +4933,6 @@ private IRubyObject trTrans19(ThreadContext context, IRubyObject src, IRubyObjec
clen = codeLength(runtime, e1, c);
tlen = enc == e1 ? clen : codeLength(runtime, enc, c);

c = trCode(c, trans, hash, cflag, last, true);
if (c < TRANS_SIZE) {
c = trans[c];
} else if (hash != null) {
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/util/StringSupport.java
Original file line number Diff line number Diff line change
@@ -988,14 +988,15 @@ else if (stable[TRANS_SIZE] && !cflag) {
buf[i] = (byte)(cflag ? 1 : 0);
}

if (tables == null) tables = new TrTables();

while ((c = trNext(tr, runtime, enc)) != errc) {
if (c < TRANS_SIZE) {
buf[c & 0xff] = (byte)(cflag ? 0 : 1);
}
else {
int key = c;

if (tables == null) tables = new TrTables();
if (table == null && (first || tables.del != null || stable[TRANS_SIZE])) {
if (cflag) {
ptable = tables.noDel;
@@ -1016,15 +1017,15 @@ else if (stable[TRANS_SIZE] && !cflag) {
for (i=0; i<TRANS_SIZE; i++) {
stable[i] = stable[i] && buf[i] != 0;
}
if (table != null && !cflag) {
if (table == null && !cflag) {
tables.del = null;
}

return tables;
}

public static boolean trFind(int c, boolean[] table, TrTables tables) {
if (c < 256) {
if (c < TRANS_SIZE) {
return table[c];
} else {
int v = c;
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/util/io/EncodingUtils.java
Original file line number Diff line number Diff line change
@@ -686,7 +686,9 @@ public static int encAscget(byte[] pBytes, int p, int e, int[] len, Encoding enc
int c;
int l;

// if e < p check unnecessary
if (e <= p) {
return -1;
}

if (encAsciicompat(enc)) {
c = pBytes[p] & 0xFF;