Skip to content

Commit

Permalink
Simplify while+break into do-while.
Browse files Browse the repository at this point in the history
Fixes #3577

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=265464337
  • Loading branch information
Mixpa authored and cpovirk committed Aug 26, 2019
1 parent 93ce68b commit 11a2cf1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Expand Up @@ -727,12 +727,9 @@ static char[] randomChars(Random rand, int size) {
Set<Character> chars = new HashSet<>(size);
for (int i = 0; i < size; i++) {
char c;
while (true) {
do {
c = (char) rand.nextInt(Character.MAX_VALUE - Character.MIN_VALUE + 1);
if (!chars.contains(c)) {
break;
}
}
} while (chars.contains(c));
chars.add(c);
}
char[] retValue = new char[chars.size()];
Expand Down
7 changes: 2 additions & 5 deletions guava-tests/test/com/google/common/base/CharMatcherTest.java
Expand Up @@ -727,12 +727,9 @@ static char[] randomChars(Random rand, int size) {
Set<Character> chars = new HashSet<>(size);
for (int i = 0; i < size; i++) {
char c;
while (true) {
do {
c = (char) rand.nextInt(Character.MAX_VALUE - Character.MIN_VALUE + 1);
if (!chars.contains(c)) {
break;
}
}
} while (chars.contains(c));
chars.add(c);
}
char[] retValue = new char[chars.size()];
Expand Down

0 comments on commit 11a2cf1

Please sign in to comment.