From c1dde60312782619e0e58e4012b93d851a8f2aeb Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 31 Jul 2023 13:13:25 +0200 Subject: [PATCH] Ensure toArray(TYPE::new) is not used as it's less efficient than toArray(TYPE.EMPTY_ARRAY) --- src/main/.checkstyle_checks.xml | 10 +++++++--- .../java/org/truffleruby/parser/ast/ArgsParseNode.java | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/.checkstyle_checks.xml b/src/main/.checkstyle_checks.xml index a4be9d466c0c..7e3549e28180 100644 --- a/src/main/.checkstyle_checks.xml +++ b/src/main/.checkstyle_checks.xml @@ -195,15 +195,19 @@ - + - + - + + + + + diff --git a/src/main/java/org/truffleruby/parser/ast/ArgsParseNode.java b/src/main/java/org/truffleruby/parser/ast/ArgsParseNode.java index 81fb62443ce8..ae11809b9d1d 100644 --- a/src/main/java/org/truffleruby/parser/ast/ArgsParseNode.java +++ b/src/main/java/org/truffleruby/parser/ast/ArgsParseNode.java @@ -38,6 +38,7 @@ import java.util.Arrays; import java.util.List; +import org.truffleruby.core.string.StringUtils; import org.truffleruby.language.SourceIndexLength; import org.truffleruby.language.methods.Arity; import org.truffleruby.parser.Helpers; @@ -153,7 +154,7 @@ private Arity createArity() { final List keywords = new ArrayList<>(requiredKeywords); keywords.addAll(optionalKeywords); - keywordArguments = keywords.toArray(String[]::new); + keywordArguments = keywords.toArray(StringUtils.EMPTY_STRING_ARRAY); requiredKeywordArgumentsCount = requiredKeywords.size(); } else { keywordArguments = Arity.NO_KEYWORDS;