Skip to content

Commit 39f9d8c

Browse files
naotojpull[bot]
authored andcommitted
8321059: Unneeded array assignments in MergeCollation and CompactByteArray
Reviewed-by: jlu, bpb, rriggs
1 parent 5bb3ad8 commit 39f9d8c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/java.base/share/classes/java/text/MergeCollation.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -68,8 +68,6 @@ final class MergeCollation {
6868
*/
6969
public MergeCollation(String pattern) throws ParseException
7070
{
71-
for (int i = 0; i < statusArray.length; i++)
72-
statusArray[i] = 0;
7371
setPattern(pattern);
7472
}
7573

src/java.base/share/classes/sun/text/CompactByteArray.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
package sun.text;
4040

4141

42+
import java.util.Arrays;
43+
4244
/**
4345
* class CompactATypeArray : use only on primitive data types
4446
* Provides a compact way to store information that is indexed by Unicode
@@ -77,12 +79,11 @@ public CompactByteArray(byte defaultValue)
7779
values = new byte[UNICODECOUNT];
7880
indices = new short[INDEXCOUNT];
7981
hashes = new int[INDEXCOUNT];
80-
for (i = 0; i < UNICODECOUNT; ++i) {
81-
values[i] = defaultValue;
82+
if (defaultValue != (byte)0) {
83+
Arrays.fill(values, defaultValue);
8284
}
8385
for (i = 0; i < INDEXCOUNT; ++i) {
8486
indices[i] = (short)(i<<BLOCKSHIFT);
85-
hashes[i] = 0;
8687
}
8788
isCompact = false;
8889
}

0 commit comments

Comments
 (0)