Skip to content

Commit 412bbe5

Browse files
committed
[refactor] use a Set for contains checking - like we do already
1 parent 08ae555 commit 412bbe5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/org/jruby/ext/openssl/Cipher.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static final class Algorithm {
253253
};
254254

255255
static {
256-
KNOWN_BLOCK_MODES = new HashSet<String>();
256+
KNOWN_BLOCK_MODES = new HashSet<>(10, 1);
257257
for ( String mode : OPENSSL_BLOCK_MODES ) KNOWN_BLOCK_MODES.add(mode);
258258
KNOWN_BLOCK_MODES.add("CTR");
259259
KNOWN_BLOCK_MODES.add("CTS"); // not supported by OpenSSL
@@ -262,8 +262,15 @@ public static final class Algorithm {
262262
}
263263

264264
// Subset of KNOWN_BLOCK_MODES that do not require padding (and shouldn't have it by default).
265-
private static final List<String> NO_PADDING_BLOCK_MODES = Arrays.asList(
266-
"CFB", "CFB8", "OFB", "CTR", "GCM");
265+
private static final Set<String> NO_PADDING_BLOCK_MODES;
266+
static {
267+
NO_PADDING_BLOCK_MODES = new HashSet<>(6, 1);
268+
NO_PADDING_BLOCK_MODES.add("CFB");
269+
NO_PADDING_BLOCK_MODES.add("CFB8");
270+
NO_PADDING_BLOCK_MODES.add("OFB");
271+
NO_PADDING_BLOCK_MODES.add("CTR");
272+
NO_PADDING_BLOCK_MODES.add("GCM");
273+
}
267274

268275
// Ruby to Java name String (or FALSE)
269276
static final HashMap<String, String[]> supportedCiphers = new LinkedHashMap<String, String[]>(120, 1);

0 commit comments

Comments
 (0)