From: Alex Rousskov Date: Wed, 21 Aug 2024 07:09:15 +0000 (+0000) Subject: Optimization: Do not zero-terminate Server::inBuf (#1889) X-Git-Tag: SQUID_7_0_1~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=46b10098e9a62c4d822d1dba8a013e8f8dc25a0d;p=thirdparty%2Fsquid.git Optimization: Do not zero-terminate Server::inBuf (#1889) ... when storing unencoded request body bytes in ConnStateData::bodyPipe Calling SBuf::c_str() is unnecessary in this context because BodyPipe::append() does not need/expect a zero-terminated buffer. The call is relatively expensive when the previous Comm::ReadNow() was able to fill the entire inBuf trailing space, which is a common occurrence because Server::maybeMakeSpaceAvailable() uses CLIENT_REQ_BUF_SZ as idealSpace size, and CLIENT_REQ_BUF_SZ is hard-coded to just 4096 bytes. The call was added in 2014 commit e7287625 that converted inBuf to SBuf. --- diff --git a/src/client_side.cc b/src/client_side.cc index 487d3768c1..fe45fc9749 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1957,7 +1957,7 @@ ConnStateData::handleRequestBodyData() } } else { // identity encoding debugs(33,5, "handling plain request body for " << clientConnection); - const size_t putSize = bodyPipe->putMoreData(inBuf.c_str(), inBuf.length()); + const auto putSize = bodyPipe->putMoreData(inBuf.rawContent(), inBuf.length()); if (putSize > 0) consumeInput(putSize);