Skip to content

Commit 0e1027c

Browse files
committed
Use intermediate variables to flatten toCharacterList loop body
1 parent e492353 commit 0e1027c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

app/src/main/java/io/github/yawnoc/utilities/Stringy.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,10 @@ public static List<String> toCharacterList(final String string)
118118
final int codePointCount = string.codePointCount(0, string.length());
119119
for (int codePointIndex = 0; codePointIndex < codePointCount; codePointIndex++)
120120
{
121-
characters.add(
122-
string.substring(
123-
string.offsetByCodePoints(0, codePointIndex),
124-
string.offsetByCodePoints(0, codePointIndex + 1)
125-
)
126-
);
121+
final int startIndex = string.offsetByCodePoints(0, codePointIndex);
122+
final int endIndex = string.offsetByCodePoints(0, codePointIndex + 1);
123+
final String character = string.substring(startIndex, endIndex);
124+
characters.add(character);
127125
}
128126

129127
return characters;

0 commit comments

Comments
 (0)