Skip to content

Commit 7e1b920

Browse files
committed
avoid map rehashing during initialization
1 parent 5b38625 commit 7e1b920

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -384,22 +384,22 @@ public class CipherStrings {
384384
public final static String TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA = "AECDH-AES128-SHA";
385385
public final static String TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA = "AECDH-AES256-SHA";
386386

387-
final static class Def implements Comparable<Def>, Cloneable {
388-
389-
public final int valid;
390-
public final String name;
391-
public final long id;
392-
public final long algorithms;
393-
public final long algo_strength;
394-
public final long algorithm2;
395-
public final int strength_bits;
396-
public final int alg_bits;
397-
public final long mask;
398-
public final long mask_strength;
387+
static final class Def implements Comparable<Def>, Cloneable {
388+
389+
final int valid;
390+
final String name;
391+
final long id;
392+
final long algorithms;
393+
final long algo_strength;
394+
final long algorithm2;
395+
final int strength_bits;
396+
final int alg_bits;
397+
final long mask;
398+
final long mask_strength;
399399

400400
private volatile String cipherSuite;
401401

402-
public Def(int valid, String name, long id, long algorithms, long algo_strength, long algorithm2, int strength_bits, int alg_bits, long mask, long mask_strength) {
402+
Def(int valid, String name, long id, long algorithms, long algo_strength, long algorithm2, int strength_bits, int alg_bits, long mask, long mask_strength) {
403403
this.valid = valid;
404404
this.name = name;
405405
this.id = id;
@@ -580,7 +580,7 @@ private static Collection<Def> matchingPattern(
580580
private final static Map<String, String> SuiteToOSSL;
581581

582582
static {
583-
Definitions = new HashMap<String, Def>(48);
583+
Definitions = new HashMap<String, Def>( 48, 1 );
584584
Definitions.put(SSL_TXT_ALL,new Def(0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL & ~SSL_kECDH & ~SSL_kECDHE, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL));
585585
Definitions.put(SSL_TXT_CMPALL,new Def(0,SSL_TXT_CMPALL,0,SSL_eNULL,0,0,0,0,SSL_ENC_MASK,0));
586586
Definitions.put(SSL_TXT_CMPDEF,new Def(0,SSL_TXT_CMPDEF,0,SSL_ADH, 0,0,0,0,SSL_AUTH_MASK,0));
@@ -627,7 +627,7 @@ private static Collection<Def> matchingPattern(
627627
Definitions.put(SSL_TXT_MEDIUM,new Def(0,SSL_TXT_MEDIUM,0, 0,SSL_MEDIUM, 0,0,0,0,SSL_STRONG_MASK));
628628
Definitions.put(SSL_TXT_HIGH,new Def(0,SSL_TXT_HIGH, 0, 0, SSL_HIGH, 0,0,0,0,SSL_STRONG_MASK));
629629

630-
Ciphers = new ArrayList<Def>( 100 );
630+
Ciphers = new ArrayList<Def>( 96 );
631631
/* Cipher 01 */
632632
Ciphers.add(new Def(
633633
1,
@@ -1808,10 +1808,10 @@ private static Collection<Def> matchingPattern(
18081808
SSL_ALL_STRENGTHS
18091809
));
18101810

1811-
CipherNames = new HashMap<String, Def>(Ciphers.size());
1811+
CipherNames = new HashMap<String, Def>(Ciphers.size() + 1, 1);
18121812
for ( Def def : Ciphers ) CipherNames.put(def.name, def);
18131813

1814-
SuiteToOSSL = new HashMap<String, String>(80);
1814+
SuiteToOSSL = new HashMap<String, String>( 72, 1 );
18151815
SuiteToOSSL.put("SSL_RSA_WITH_NULL_MD5","NULL-MD5");
18161816
SuiteToOSSL.put("SSL_RSA_WITH_NULL_SHA","NULL-SHA");
18171817
SuiteToOSSL.put("SSL_RSA_EXPORT_WITH_RC4_40_MD5","EXP-RC4-MD5");

0 commit comments

Comments
 (0)