Skip to content

Commit

Permalink
Removed a static method that wasn't being used anywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Dec 24, 2014
1 parent aff47e4 commit ecee892
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions core/src/main/java/org/jruby/RubyRegexp.java
Expand Up @@ -1965,91 +1965,6 @@ public static IRubyObject match_last(IRubyObject match) {
return nth_match(i, match);
}

static RubyString regsub(RubyString str, RubyString src, Matcher matcher, Encoding enc) {
Region regs = matcher.getRegion();

int no = -1;
ByteList bs = str.getByteList();
int p = bs.getBegin();
int s = p;
int end = p + bs.getRealSize();
byte[]bytes = bs.getUnsafeBytes();

ByteList srcbs = src.getByteList();

ByteList val = null;

while (s < end) {
int ss = s;
int c = bytes[s] & 0xff;
int l = enc.length(bytes, s++, end);
if (l != 1) {
s += l - 1;
continue;
}
if (c != '\\' || s == end) continue;
if (val == null) val = new ByteList(ss - p);

val.append(bytes, p, ss - p);
c = bytes[s++] & 0xff;
p = s;

switch (c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
no = c - '0';
break;
case '&':
no = 0;
break;
case '`':
val.append( srcbs.getUnsafeBytes(), srcbs.getBegin(), matcher.getBegin());
continue;
case '\'':
val.append(srcbs.getUnsafeBytes(), srcbs.getBegin() + matcher.getEnd(), srcbs.getRealSize() - matcher.getEnd());
continue;
case '+':
if (regs == null) {
if (matcher.getBegin() == -1) {
no = 0;
continue;
}
} else {
no = regs.numRegs - 1;
while (regs.beg[no] == -1 && no > 0) no--;
if (no == 0) continue;
}
break;
case '\\':
val.append(bytes, s - 1, 1);
continue;
default:
val.append(bytes, s - 2, 2);
continue;
}

if (regs != null) {
if (no >= 0) {
if (no >= regs.numRegs || regs.beg[no] == -1) continue;
val.append(srcbs.getUnsafeBytes(), srcbs.getBegin() + regs.beg[no], regs.end[no] - regs.beg[no]);
}
} else {
if (no != 0 || matcher.getBegin() == -1) continue;
val.append(srcbs.getUnsafeBytes(), srcbs.getBegin() + matcher.getBegin(), matcher.getEnd() - matcher.getBegin());
}
}

if (p < end) {
if (val == null) {
return RubyString.newString(str.getRuntime(), bs.makeShared(p - bs.getBegin(), end - p));
} else {
val.append(bytes, p, end - p);
}
}
if (val == null) return str;
return RubyString.newString(str.getRuntime(), val);
}

// MRI: ASCGET macro from rb_reg_regsub
private static final int ASCGET(boolean acompat, byte[] sBytes, int s, int e, int[] cl, Encoding strEnc) {
if (acompat) {
Expand Down

0 comments on commit ecee892

Please sign in to comment.