Skip to content

Commit 979e994

Browse files
committed
iterate over RubyArray directly
1 parent da097b8 commit 979e994

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ private RubyArray matchedCiphers(final ThreadContext context) {
434434
final Collection<CipherStrings.Def> cipherDefs =
435435
CipherStrings.matchingCiphers(this.ciphers, supported, false);
436436

437-
final RubyArray cipherList = runtime.newArray(cipherDefs.size());
437+
final RubyArray cipherList = runtime.newArray( cipherDefs.size() );
438438

439439
for ( CipherStrings.Def def : cipherDefs ) {
440440
final RubyArray cipher = runtime.newArray(4);
@@ -458,13 +458,14 @@ public IRubyObject set_ciphers(final ThreadContext context, final IRubyObject ci
458458
this.ciphers = CipherStrings.SSL_DEFAULT_CIPHER_LIST;
459459
}
460460
else if ( ciphers instanceof RubyArray ) {
461-
StringBuilder builder = new StringBuilder();
461+
final RubyArray ciphs = (RubyArray) ciphers;
462+
StringBuilder cipherStr = new StringBuilder();
462463
String sep = "";
463-
for (IRubyObject obj : ((RubyArray) ciphers).toJavaArray()) {
464-
builder.append(sep).append(obj.toString());
464+
for ( int i = 0; i < ciphs.size(); i++ ) {
465+
cipherStr.append(sep).append( ciphs.eltInternal(i).toString() );
465466
sep = ":";
466467
}
467-
this.ciphers = builder.toString();
468+
this.ciphers = cipherStr.toString();
468469
}
469470
else {
470471
this.ciphers = ciphers.asString().toString();

0 commit comments

Comments
 (0)