From f68c62cdfc4d66def52aa73fbc2ad58acc32af62 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 31 Mar 2016 13:05:11 +0300 Subject: QSslSocket (Mac): optimize string usage Wrap C-string in QL1S to prevent memory allocation. Replace startsWith() with comparing to first element of (existing) splitting result. Change-Id: Id47a0c350e4027abecd1394c1ee5dec8f346af00 Reviewed-by: Marc Mutz Reviewed-by: Edward Welbourne --- src/network/ssl/qsslsocket_mac.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/network/ssl') diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index da9c8c165b..99ae7923f4 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -871,9 +871,9 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui if (bits.size() >= 2) { if (bits.size() == 2 || bits.size() == 3) { ciph.d->keyExchangeMethod = QLatin1String("RSA"); - } else if (ciph.d->name.startsWith("DH-") || ciph.d->name.startsWith("DHE-")) { + } else if (bits.front() == QLatin1String("DH") || bits.front() == QLatin1String("DHE")) { ciph.d->keyExchangeMethod = QLatin1String("DH"); - } else if (ciph.d->name.startsWith("ECDH-") || ciph.d->name.startsWith("ECDHE-")) { + } else if (bits.front() == QLatin1String("ECDH") || bits.front() == QLatin1String("ECDHE")) { ciph.d->keyExchangeMethod = QLatin1String("ECDH"); } else { qCWarning(lcSsl) << "Unknown Kx" << ciph.d->name; @@ -881,35 +881,35 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui if (bits.size() == 2 || bits.size() == 3) { ciph.d->authenticationMethod = QLatin1String("RSA"); - } else if (ciph.d->name.contains("-ECDSA-")) { + } else if (ciph.d->name.contains(QLatin1String("-ECDSA-"))) { ciph.d->authenticationMethod = QLatin1String("ECDSA"); - } else if (ciph.d->name.contains("-RSA-")) { + } else if (ciph.d->name.contains(QLatin1String("-RSA-"))) { ciph.d->authenticationMethod = QLatin1String("RSA"); } else { qCWarning(lcSsl) << "Unknown Au" << ciph.d->name; } - if (ciph.d->name.contains("RC4-")) { + if (ciph.d->name.contains(QLatin1String("RC4-"))) { ciph.d->encryptionMethod = QLatin1String("RC4(128)"); ciph.d->bits = 128; ciph.d->supportedBits = 128; - } else if (ciph.d->name.contains("DES-CBC3-")) { + } else if (ciph.d->name.contains(QLatin1String("DES-CBC3-"))) { ciph.d->encryptionMethod = QLatin1String("3DES(168)"); ciph.d->bits = 168; ciph.d->supportedBits = 168; - } else if (ciph.d->name.contains("AES128-")) { + } else if (ciph.d->name.contains(QLatin1String("AES128-"))) { ciph.d->encryptionMethod = QLatin1String("AES(128)"); ciph.d->bits = 128; ciph.d->supportedBits = 128; - } else if (ciph.d->name.contains("AES256-GCM")) { + } else if (ciph.d->name.contains(QLatin1String("AES256-GCM"))) { ciph.d->encryptionMethod = QLatin1String("AESGCM(256)"); ciph.d->bits = 256; ciph.d->supportedBits = 256; - } else if (ciph.d->name.contains("AES256-")) { + } else if (ciph.d->name.contains(QLatin1String("AES256-"))) { ciph.d->encryptionMethod = QLatin1String("AES(256)"); ciph.d->bits = 256; ciph.d->supportedBits = 256; - } else if (ciph.d->name.contains("NULL-")) { + } else if (ciph.d->name.contains(QLatin1String("NULL-"))) { ciph.d->encryptionMethod = QLatin1String("NULL"); } else { qCWarning(lcSsl) << "Unknown Enc" << ciph.d->name; -- cgit v1.2.3