Skip to content

Commit

Permalink
Merge pull request square#2866 from kilink/avoid-copy
Browse files Browse the repository at this point in the history
Avoid unnecessary copying in ConnectionSpec
  • Loading branch information
swankjesse authored Sep 18, 2016
2 parents 5f6a7a8 + 12d44f1 commit 3ea7be9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions okhttp/src/main/java/okhttp3/ConnectionSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/
package okhttp3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.net.ssl.SSLSocket;

import static okhttp3.internal.Util.concat;
import static okhttp3.internal.Util.immutableList;
import static okhttp3.internal.Util.indexOf;
import static okhttp3.internal.Util.intersect;

Expand Down Expand Up @@ -102,11 +103,11 @@ public boolean isTls() {
public List<CipherSuite> cipherSuites() {
if (cipherSuites == null) return null;

CipherSuite[] result = new CipherSuite[cipherSuites.length];
for (int i = 0; i < cipherSuites.length; i++) {
result[i] = CipherSuite.forJavaName(cipherSuites[i]);
List<CipherSuite> result = new ArrayList<>(cipherSuites.length);
for (String cipherSuite : cipherSuites) {
result.add(CipherSuite.forJavaName(cipherSuite));
}
return immutableList(result);
return Collections.unmodifiableList(result);
}

/**
Expand All @@ -116,11 +117,11 @@ public List<CipherSuite> cipherSuites() {
public List<TlsVersion> tlsVersions() {
if (tlsVersions == null) return null;

TlsVersion[] result = new TlsVersion[tlsVersions.length];
for (int i = 0; i < tlsVersions.length; i++) {
result[i] = TlsVersion.forJavaName(tlsVersions[i]);
List<TlsVersion> result = new ArrayList<>(tlsVersions.length);
for (String tlsVersion : tlsVersions) {
result.add(TlsVersion.forJavaName(tlsVersion));
}
return immutableList(result);
return Collections.unmodifiableList(result);
}

public boolean supportsTlsExtensions() {
Expand Down

0 comments on commit 3ea7be9

Please sign in to comment.