From 2272e8f2284d475a6a43e10f4db711771e9bbc2a Mon Sep 17 00:00:00 2001 From: Vladimir Belyavsky Date: Sun, 21 Apr 2024 20:09:26 +0300 Subject: [PATCH] QHttp2Connection: Use QHash::constFind() to avoid unnecessary detaches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QHash::constFind() instead of non-const QHash::find() where applicable to avoid unnecessary detaches. Change-Id: I77022c1b2fffca45181b3e1271dfb123b4691047 Reviewed-by: MÃ¥rten Nordheim --- src/network/access/qhttp2connection.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp index d9900c31574..8560e0da386 100644 --- a/src/network/access/qhttp2connection.cpp +++ b/src/network/access/qhttp2connection.cpp @@ -1222,8 +1222,8 @@ void QHttp2Connection::handleDATA() sessionReceiveWindowSize -= inboundFrame.payloadSize(); - auto it = m_streams.find(streamID); - if (it != m_streams.end() && it.value()) + auto it = m_streams.constFind(streamID); + if (it != m_streams.cend() && it.value()) it.value()->handleDATA(inboundFrame); if (sessionReceiveWindowSize < maxSessionReceiveWindowSize / 2) { @@ -1581,9 +1581,9 @@ void QHttp2Connection::handleContinuedHEADERS() const auto streamID = continuedFrames[0].streamID(); - const auto streamIt = m_streams.find(streamID); + const auto streamIt = m_streams.constFind(streamID); if (firstFrameType == FrameType::HEADERS) { - if (streamIt != m_streams.end()) { + if (streamIt != m_streams.cend()) { QHttp2Stream *stream = streamIt.value(); if (stream->state() != QHttp2Stream::State::HalfClosedLocal && stream->state() != QHttp2Stream::State::ReservedRemote @@ -1619,7 +1619,7 @@ void QHttp2Connection::handleContinuedHEADERS() // not include a complete and valid set of header fields or the :method // pseudo-header field identifies a method that is not safe, it MUST // respond with a stream error (Section 5.4.2) of type PROTOCOL_ERROR." - if (streamIt != m_streams.end()) + if (streamIt != m_streams.cend()) (*streamIt)->sendRST_STREAM(PROTOCOL_ERROR); return; } @@ -1632,7 +1632,7 @@ void QHttp2Connection::handleContinuedHEADERS() return connectionError(FRAME_SIZE_ERROR, "HEADERS frame too large"); } - if (streamIt == m_streams.end()) // No more processing without a stream from here on. + if (streamIt == m_streams.cend()) // No more processing without a stream from here on. return; switch (firstFrameType) {