]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Optimization: Do not zero-terminate Server::inBuf (#1889)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 21 Aug 2024 07:09:15 +0000 (07:09 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 21 Aug 2024 14:41:21 +0000 (14:41 +0000)
... 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.

src/client_side.cc

index 487d3768c1d2a563ee3dd8952010719e9123e1bf..fe45fc97497c6d575a2dc8ef21c2fde85fb81bdf 100644 (file)
@@ -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);