Skip to content

Commit 7be8bcf

Browse files
committed
refactor: remove PRIME_NUMBER_ARRAY & simplify stream
1 parent cd6ace2 commit 7be8bcf

File tree

1 file changed

+1
-13
lines changed
  • src/main/java/io/github/thibaultmeyer/cuid

1 file changed

+1
-13
lines changed

src/main/java/io/github/thibaultmeyer/cuid/CUID.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ public static boolean isValid(final String cuidAsString) {
119119
&& (cuidAsString.length() == CUIDv1.LENGTH_STANDARD && cuidAsString.startsWith(CUIDv1.START_CHARACTER) // Version 1
120120
|| (!cuidAsString.isEmpty())) // Version 2
121121
&& cuidAsString.chars()
122-
.filter(c -> !((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')))
123-
.count() == 0;
122+
.filter(c -> !((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))).findAny().isEmpty();
124123
}
125124

126125
/**
@@ -239,17 +238,6 @@ private static final class CUIDv2 {
239238
private static final char[] ALPHABET_ARRAY = new char[]{
240239
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
241240
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
242-
private static final int[] PRIME_NUMBER_ARRAY = new int[]{
243-
109717,
244-
109721,
245-
109741,
246-
109751,
247-
109789,
248-
109793,
249-
109807,
250-
109819,
251-
109829,
252-
109831};
253241

254242
// CUID configuration
255243
private static final int LENGTH_STANDARD = 24;

0 commit comments

Comments
 (0)