QHttp2Connection: Use QHash::constFind() to avoid unnecessary detaches
Use QHash::constFind() instead of non-const QHash::find() where applicable to avoid unnecessary detaches. Change-Id: I77022c1b2fffca45181b3e1271dfb123b4691047 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
5f0ed0ac0d
commit
2272e8f228
@ -1222,8 +1222,8 @@ void QHttp2Connection::handleDATA()
|
|||||||
|
|
||||||
sessionReceiveWindowSize -= inboundFrame.payloadSize();
|
sessionReceiveWindowSize -= inboundFrame.payloadSize();
|
||||||
|
|
||||||
auto it = m_streams.find(streamID);
|
auto it = m_streams.constFind(streamID);
|
||||||
if (it != m_streams.end() && it.value())
|
if (it != m_streams.cend() && it.value())
|
||||||
it.value()->handleDATA(inboundFrame);
|
it.value()->handleDATA(inboundFrame);
|
||||||
|
|
||||||
if (sessionReceiveWindowSize < maxSessionReceiveWindowSize / 2) {
|
if (sessionReceiveWindowSize < maxSessionReceiveWindowSize / 2) {
|
||||||
@ -1581,9 +1581,9 @@ void QHttp2Connection::handleContinuedHEADERS()
|
|||||||
|
|
||||||
const auto streamID = continuedFrames[0].streamID();
|
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 (firstFrameType == FrameType::HEADERS) {
|
||||||
if (streamIt != m_streams.end()) {
|
if (streamIt != m_streams.cend()) {
|
||||||
QHttp2Stream *stream = streamIt.value();
|
QHttp2Stream *stream = streamIt.value();
|
||||||
if (stream->state() != QHttp2Stream::State::HalfClosedLocal
|
if (stream->state() != QHttp2Stream::State::HalfClosedLocal
|
||||||
&& stream->state() != QHttp2Stream::State::ReservedRemote
|
&& 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
|
// 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
|
// 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."
|
// 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);
|
(*streamIt)->sendRST_STREAM(PROTOCOL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1632,7 +1632,7 @@ void QHttp2Connection::handleContinuedHEADERS()
|
|||||||
return connectionError(FRAME_SIZE_ERROR, "HEADERS frame too large");
|
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;
|
return;
|
||||||
|
|
||||||
switch (firstFrameType) {
|
switch (firstFrameType) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user