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

Commits on Nov 22, 2016

  1. Copy the full SHA
    b2568f2 View commit details
  2. Copy the full SHA
    b410c61 View commit details
Showing with 83 additions and 8 deletions.
  1. +28 −2 core/src/main/java/org/jruby/RubyArray.java
  2. +55 −6 core/src/main/java/org/jruby/RubyString.java
30 changes: 28 additions & 2 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -1569,8 +1569,8 @@ public IRubyObject at(IRubyObject pos) {
/** rb_ary_concat
*
*/
@JRubyMethod(name = "concat", required = 1)
public RubyArray concat(IRubyObject obj) {
@JRubyMethod(name = "concat")
public RubyArray concat(ThreadContext context, IRubyObject obj) {
modifyCheck();

RubyArray ary = obj.convertToArray();
@@ -1580,6 +1580,32 @@ public RubyArray concat(IRubyObject obj) {
return this;
}

/** rb_ary_concat
*
*/
@JRubyMethod(name = "concat", rest = true)
public RubyArray concat(ThreadContext context, IRubyObject[] objs) {
Ruby runtime = context.runtime;

modifyCheck();

if (objs.length > 0) {
RubyArray tmp = newArray(runtime, objs.length);

for (IRubyObject obj : objs) {
tmp.concat(context, obj);
}

append(tmp);
}

return this;
}

public RubyArray concat(IRubyObject obj) {
return concat(getRuntime().getCurrentContext(), obj);
}

@Deprecated
public RubyArray concat19(IRubyObject obj) {
return concat(obj);
61 changes: 55 additions & 6 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1546,7 +1546,7 @@ private IRubyObject initialize(ThreadContext context, IRubyObject arg0, RubyHash
if (opts != null) {
IRubyObject encoding = opts.fastARef(context.runtime.newSymbol("encoding"));

if (!encoding.isNil()) {
if (!(encoding == null || encoding.isNil())) {
modify();
setEncodingAndCodeRange(runtime.getEncodingService().getEncodingFromObject(encoding), CR_UNKNOWN);
}
@@ -2238,12 +2238,8 @@ public RubyString append19(IRubyObject other) {
/** rb_str_concat
*
*/
public RubyString concat(IRubyObject other) {
return concat19(getRuntime().getCurrentContext(), other);
}

@JRubyMethod(name = {"concat", "<<"})
public RubyString concat19(ThreadContext context, IRubyObject other) {
public RubyString concat(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (other instanceof RubyFixnum) {
long c = RubyNumeric.num2long(other);
@@ -2263,6 +2259,37 @@ public RubyString concat19(ThreadContext context, IRubyObject other) {
return append19(other);
}

/** rb_str_concat
*
*/
@JRubyMethod(name = {"concat", "<<"}, rest = true)
public RubyString concat(ThreadContext context, IRubyObject[] objs) {
Ruby runtime = context.runtime;

modifyCheck();

if (objs.length > 0) {
RubyString tmp = newStringLight(runtime, objs.length, getEncoding());

for (IRubyObject obj : objs) {
tmp.concat(context, obj);
}

append(tmp);
}

return this;
}

public RubyString concat(IRubyObject other) {
return concat(getRuntime().getCurrentContext(), other);
}

@Deprecated
public RubyString concat19(ThreadContext context, IRubyObject other) {
return concat(context, other);
}

private RubyString concatNumeric(Ruby runtime, int c) {
Encoding enc = value.getEncoding();
int cl;
@@ -2299,6 +2326,28 @@ public IRubyObject prepend(ThreadContext context, IRubyObject other) {
return replace19(other.convertToString().op_plus19(context, this));
}

/**
* rb_str_prepend
*/
@JRubyMethod(rest = true)
public IRubyObject prepend(ThreadContext context, IRubyObject[] objs) {
Ruby runtime = context.runtime;

modifyCheck();

if (objs.length > 0) {
RubyString tmp = newStringLight(runtime, objs.length, getEncoding());

for (IRubyObject obj : objs) {
tmp.concat(context, obj);
}

replaceInternal19(0, 0, tmp);
}

return this;
}

/** rb_str_crypt
*
*/