Skip to content

Commit b4a36e1

Browse files
committed
Avoid an extra copy of a Ruby array for splat calls
* This partially reverts commit 7d45bc9.
1 parent 4738bfe commit b4a36e1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main/java/org/truffleruby/language/exceptions/RescueSplatNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public RescueSplatNode(RubyLanguage language, RubyNode handlingClassesArray, Rub
3535
SplatCastNode.NilBehavior.EMPTY_ARRAY,
3636
false,
3737
handlingClassesArray);
38+
this.splatCastNode.doNotCopy();
3839
this.stores = ArrayStoreLibrary.getFactory().createDispatched(ArrayGuards.storageStrategyLimit());
3940
}
4041

src/main/java/org/truffleruby/parser/BodyTranslator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,14 @@ protected ArgumentsAndBlockTranslation translateArgumentsAndBlock(SourceIndexLen
700700
argumentsTranslated[i] = arguments[i].accept(this);
701701
}
702702

703+
if (isSplatted) {
704+
assert argumentsTranslated.length == 1;
705+
// No need to copy the array for call(*splat), the elements will be copied to the frame arguments
706+
if (argumentsTranslated[0] instanceof SplatCastNode) {
707+
((SplatCastNode) argumentsTranslated[0]).doNotCopy();
708+
}
709+
}
710+
703711
ParseNode blockPassNode = null;
704712
if (iterNode instanceof BlockPassParseNode) {
705713
blockPassNode = ((BlockPassParseNode) iterNode).getBodyNode();

0 commit comments

Comments
 (0)