Skip to content

Commit

Permalink
elide unnecessary string constructors/copies
Browse files Browse the repository at this point in the history
Summary: elides some string copies in QuicError

Reviewed By: sharmafb

Differential Revision: D57633227

fbshipit-source-id: 2de48895ae221e052438112371f10e50bf47353f
  • Loading branch information
hanidamlaj authored and facebook-github-bot committed May 26, 2024
1 parent 3d97f15 commit 50cff27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions proxygen/lib/http/session/HQSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,10 @@ void HQSession::closeWhenIdle() {
}

void HQSession::dropConnection(const std::string& errorMsg) {
auto msg = errorMsg.empty() ? "Stopping" : errorMsg;
dropConnectionSync(quic::QuicError(HTTP3::ErrorCode::HTTP_NO_ERROR, msg),
kErrorDropped);
std::string msg = errorMsg.empty() ? "Stopping" : errorMsg;
dropConnectionSync(
quic::QuicError(HTTP3::ErrorCode::HTTP_NO_ERROR, std::move(msg)),
kErrorDropped);
}

void HQSession::dropConnectionAsync(quic::QuicError errorCode,
Expand Down Expand Up @@ -1851,7 +1852,8 @@ void HQSession::handleSessionError(HQStreamBase* stream,
// close received from the remote, we may have other readError callbacks on
// other streams after this one. So run in the next loop callback, in this
// same loop
dropConnectionAsync(quic::QuicError(appError, appErrorMsg), proxygenError);
dropConnectionAsync(quic::QuicError(appError, std::move(appErrorMsg)),
proxygenError);
}

uint64_t HQSession::writeRequestStreams(uint64_t maxEgress) noexcept {
Expand Down
6 changes: 4 additions & 2 deletions proxygen/lib/http/session/test/MockQuicSocketDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,11 @@ class MockQuicSocketDriver : public folly::EventBase::LoopCallback {
stream.readCB = nullptr;
stream.peekCB = nullptr;
if (rcb) {
rcb->readError(it.first, QuicError(error.code, error.message));
rcb->readError(it.first,
QuicError(error.code, std::string(error.message)));
} else {
pcb->peekError(it.first, QuicError(error.code, error.message));
pcb->peekError(it.first,
QuicError(error.code, std::string(error.message)));
}
}
stream.readState = ERROR;
Expand Down

0 comments on commit 50cff27

Please sign in to comment.