Skip to content

Commit 23755f9

Browse files
author
Justin Lu
committedJul 28, 2023
8312411: MessageFormat.formatToCharacterIterator() can be improved
Reviewed-by: naoto
1 parent e2cb0bc commit 23755f9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎src/java.base/share/classes/java/text/MessageFormat.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -948,20 +948,16 @@ public final StringBuffer format(Object arguments, StringBuffer result,
948948
* @since 1.4
949949
*/
950950
public AttributedCharacterIterator formatToCharacterIterator(Object arguments) {
951+
Objects.requireNonNull(arguments, "arguments must not be null");
951952
StringBuffer result = new StringBuffer();
952953
ArrayList<AttributedCharacterIterator> iterators = new ArrayList<>();
953954

954-
if (arguments == null) {
955-
throw new NullPointerException(
956-
"formatToCharacterIterator must be passed non-null object");
957-
}
958955
subformat((Object[]) arguments, result, null, iterators);
959956
if (iterators.size() == 0) {
960957
return createAttributedCharacterIterator("");
961958
}
962959
return createAttributedCharacterIterator(
963-
iterators.toArray(
964-
new AttributedCharacterIterator[iterators.size()]));
960+
iterators.toArray(new AttributedCharacterIterator[0]));
965961
}
966962

967963
/**

0 commit comments

Comments
 (0)