Skip to content

Commit

Permalink
Tweaks for String#concat and String#<<. #4293
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Nov 22, 2016
1 parent b410c61 commit 12f3b2c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -2238,8 +2238,8 @@ public RubyString append19(IRubyObject other) {
/** rb_str_concat
*
*/
@JRubyMethod(name = {"concat", "<<"})
public RubyString concat(ThreadContext context, IRubyObject other) {
@JRubyMethod(name = "<<")
public RubyString concatSingle(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (other instanceof RubyFixnum) {
long c = RubyNumeric.num2long(other);
Expand All @@ -2262,7 +2262,15 @@ public RubyString concat(ThreadContext context, IRubyObject other) {
/** rb_str_concat
*
*/
@JRubyMethod(name = {"concat", "<<"}, rest = true)
@JRubyMethod(name = {"concat"})
public RubyString concat(ThreadContext context, IRubyObject obj) {
return concatSingle(context, obj);
}

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

Expand All @@ -2272,10 +2280,10 @@ public RubyString concat(ThreadContext context, IRubyObject[] objs) {
RubyString tmp = newStringLight(runtime, objs.length, getEncoding());

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

append(tmp);
append19(tmp);
}

return this;
Expand Down

0 comments on commit 12f3b2c

Please sign in to comment.