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

Commits on Jan 8, 2015

  1. Copy the full SHA
    819c265 View commit details
  2. Copy the full SHA
    200de99 View commit details
Showing with 18 additions and 23 deletions.
  1. +18 −23 core/src/main/java/org/jruby/RubyMatchData.java
41 changes: 18 additions & 23 deletions core/src/main/java/org/jruby/RubyMatchData.java
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.Visibility;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;

@@ -458,53 +457,49 @@ public IRubyObject size(ThreadContext context) {
/** match_begin
*
*/
@JRubyMethod
public IRubyObject begin(ThreadContext context, IRubyObject index) {
return begin19(context, index);
}
check();

@JRubyMethod(name = "begin")
public IRubyObject begin19(ThreadContext context, IRubyObject index) {
int i = backrefNumber(index);
Ruby runtime = context.runtime;
int b = beginCommon(runtime, i);

if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) throw runtime.newIndexError("index " + i + " out of matches");

int b = regs == null ? begin : regs.beg[i];

if (b < 0) return runtime.getNil();

if (!str.singleByteOptimizable()) {
updateCharOffset();
b = charOffsets.beg[i];
}
return RubyFixnum.newFixnum(runtime, b);
}

private int beginCommon(Ruby runtime, int i) {
check();
if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) throw runtime.newIndexError("index " + i + " out of matches");
return regs == null ? begin : regs.beg[i];
return RubyFixnum.newFixnum(runtime, b);
}

/** match_end
*
*/
@JRubyMethod
public IRubyObject end(ThreadContext context, IRubyObject index) {
return end19(context, index);
}
check();

@JRubyMethod(name = "end")
public IRubyObject end19(ThreadContext context, IRubyObject index) {
int i = backrefNumber(index);
Ruby runtime = context.runtime;
int e = endCommon(runtime, i);

if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) throw runtime.newIndexError("index " + i + " out of matches");

int e = regs == null ? end : regs.end[i];

if (e < 0) return runtime.getNil();

if (!str.singleByteOptimizable()) {
updateCharOffset();
e = charOffsets.end[i];
}
return RubyFixnum.newFixnum(runtime, e);
}

private int endCommon(Ruby runtime, int i) {
check();
if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) throw runtime.newIndexError("index " + i + " out of matches");
return regs == null ? end : regs.end[i];
return RubyFixnum.newFixnum(runtime, e);
}

/** match_offset