From 28bff27b8596375c524560c386ab101da428e738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 21 Mar 2024 15:56:19 +0100 Subject: [PATCH] QHttpNetworkConnectionPrivate: move some init logic into a function Now we can nicely initialize it as a member-initializer. Do channels at the same time, NSDMI follows. Task-number: QTBUG-102855 Change-Id: I59c1fe044687500ed3a9d5878c6e4fc137114542 Reviewed-by: Edward Welbourne --- src/network/access/qhttpnetworkconnection.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 3f107b5a5b..24637e68c6 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -40,24 +40,28 @@ const int QHttpNetworkConnectionPrivate::defaultPipelineLength = 3; // This means that there are 2 requests in flight and 2 slots free that will be re-filled. const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2; +static int getPreferredActiveChannelCount(QHttpNetworkConnection::ConnectionType type, + int defaultValue) +{ + return (type == QHttpNetworkConnection::ConnectionTypeHTTP2 + || type == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) + ? 1 + : defaultValue; +} QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, QHttpNetworkConnection::ConnectionType type) : state(RunningState), networkLayerState(Unknown), hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true), - channelCount(connectionCount) + activeChannelCount(getPreferredActiveChannelCount(type, connectionCount)), + channelCount(connectionCount), channels(new QHttpNetworkConnectionChannel[channelCount]) #ifndef QT_NO_NETWORKPROXY , networkProxy(QNetworkProxy::NoProxy) #endif , preConnectRequests(0) , connectionType(type) { - channels = new QHttpNetworkConnectionChannel[channelCount]; - - activeChannelCount = (type == QHttpNetworkConnection::ConnectionTypeHTTP2 || - type == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) - ? 1 : connectionCount; // We allocate all 6 channels even if it's an HTTP/2-enabled // connection: in case the protocol negotiation via NPN/ALPN fails, // we will have normally working HTTP/1.1.