Remove unnecessary loop variable from AsciiString
. (#8711)
Motivation: Incrementing two variables in sync is not necessary when only one will do. Modifications: - Remove `j` from `for` loop and replace with `i`. - Add more unit testing scenarios to cover changed code. Results: Unnecessary variable removed.
This commit is contained in:
parent
c10ccc5dec
commit
f08e80ffd6
@ -1452,8 +1452,8 @@ public final class AsciiString implements CharSequence, Comparable<CharSequence>
|
||||
if (a.length() != b.length()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0, j = 0; i < a.length(); ++i, ++j) {
|
||||
if (!equalsIgnoreCase(a.charAt(i), b.charAt(j))) {
|
||||
for (int i = 0; i < a.length(); ++i) {
|
||||
if (!equalsIgnoreCase(a.charAt(i), b.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -240,6 +240,9 @@ public class AsciiStringCharacterTest {
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase(null, "foo"), is(false));
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase("bar", null), is(false));
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase("FoO", "fOo"), is(true));
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase("FoO", "bar"), is(false));
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase("Foo", "foobar"), is(false));
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase("foobar", "Foo"), is(false));
|
||||
|
||||
// Test variations (Ascii + String, Ascii + Ascii, String + Ascii)
|
||||
assertThat(AsciiString.contentEqualsIgnoreCase(new AsciiString("FoO"), "fOo"), is(true));
|
||||
|
Loading…
Reference in New Issue
Block a user