Skip to content

Commit 93314bb

Browse files
committed
Share a common array for empty keyword arguments.
1 parent 80df338 commit 93314bb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/main/java/org/truffleruby/core/symbol/RubySymbol.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public final class RubySymbol extends ImmutableRubyObjectNotCopyable implements
4040

4141
private static final int CLASS_SALT = 92021474; // random number, stops hashes for similar values but different classes being the same, static because we want deterministic hashes
4242

43+
public static final RubySymbol[] EMPTY_ARRAY = new RubySymbol[0];
44+
4345
public final RubyEncoding encoding;
4446
private final String string;
4547
public final TruffleString tstring;

src/main/java/org/truffleruby/language/arguments/CheckKeywordArityNode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ private Object[] findExtraKeywordArguments(RubyHash keywordArguments) {
117117

118118
static RubySymbol[] keywordsAsSymbols(RubyLanguage language, Arity arity) {
119119
final String[] names = arity.getKeywordArguments();
120+
121+
if (names.length == 0) {
122+
return RubySymbol.EMPTY_ARRAY;
123+
}
124+
120125
final RubySymbol[] symbols = new RubySymbol[names.length];
121126
for (int i = 0; i < names.length; i++) {
122127
symbols[i] = language.getSymbol(names[i]);

0 commit comments

Comments
 (0)