1
0
mirror of https://github.com/square/okhttp.git synced 2025-07-31 05:04:26 +03:00

Replace !isEmpty with isNotEmpty

This commit is contained in:
Tang HuaiZhe
2019-05-25 11:59:23 +08:00
parent 2a9ac09cf1
commit 376b9a4e59
5 changed files with 12 additions and 16 deletions

View File

@ -103,7 +103,7 @@ class DnsOverHttps internal constructor(builder: Builder) : Dns {
executeRequests(hostname, networkRequests, results, failures)
return if (!results.isEmpty()) {
return if (results.isNotEmpty()) {
results
} else {
throwBestFailure(hostname, failures)

View File

@ -357,7 +357,7 @@ class HeldCertificate(private val keyPair: KeyPair, private val certificate: X50
BasicConstraints(maxIntermediateCas))
}
if (!altNames.isEmpty()) {
if (altNames.isNotEmpty()) {
val encodableAltNames = arrayOfNulls<ASN1Encodable>(altNames.size)
for (i in 0 until altNames.size) {
val altName = altNames[i]

View File

@ -27,19 +27,15 @@ object RequestLine {
* [HttpURLConnection.getHeaderFields], so it needs to be set even if the transport is
* HTTP/2.
*/
fun get(request: Request, proxyType: Proxy.Type): String {
val result = StringBuilder()
result.append(request.method)
result.append(' ')
fun get(request: Request, proxyType: Proxy.Type) = buildString {
append(request.method)
append(' ')
if (includeAuthorityInRequestLine(request, proxyType)) {
result.append(request.url)
append(request.url)
} else {
result.append(requestPath(request.url))
append(requestPath(request.url))
}
result.append(" HTTP/1.1")
return result.toString()
append(" HTTP/1.1")
}
/**

View File

@ -128,10 +128,10 @@ object Http2 {
if (flags == 0) return ""
when (type) {
// Special case types that have 0 or 1 flag.
TYPE_SETTINGS, TYPE_PING -> return if (flags == FLAG_ACK) "ACK" else BINARY[flags]!!
TYPE_PRIORITY, TYPE_RST_STREAM, TYPE_GOAWAY, TYPE_WINDOW_UPDATE -> return BINARY[flags]!!
TYPE_SETTINGS, TYPE_PING -> return if (flags == FLAG_ACK) "ACK" else BINARY[flags]
TYPE_PRIORITY, TYPE_RST_STREAM, TYPE_GOAWAY, TYPE_WINDOW_UPDATE -> return BINARY[flags]
}
val result = if (flags < FLAGS.size) FLAGS[flags]!! else BINARY[flags]!!
val result = if (flags < FLAGS.size) FLAGS[flags]!! else BINARY[flags]
// Special case types that have overlap flag values.
return when {
type == TYPE_PUSH_PROMISE && flags and FLAG_END_PUSH_PROMISE != 0 -> {

View File

@ -231,7 +231,7 @@ class RealWebSocket(
executor!!.scheduleAtFixedRate(
PingRunnable(), pingIntervalMillis, pingIntervalMillis, MILLISECONDS)
}
if (!messageAndCloseQueue.isEmpty()) {
if (messageAndCloseQueue.isNotEmpty()) {
runWriter() // Send messages that were enqueued before we were connected.
}
}