[squid-dev] [PATCH] Faster SBuf::append

Alex Rousskov rousskov at measurement-factory.com
Thu Oct 6 16:01:02 UTC 2016


Hello,

    The attached optimization patch was inspired be reviewing the
following code:

> Parser::parse(const SBuf &aBuf)
...
> if (preservedData_.isEmpty())
>     preservedData_ = aBuf; // avoid needless memory allocation
> else
>     preservedData_.append(aBuf);

Supporting this kind of optimization automatically was a little trickier
than I thought, but I think the attached patch does that. After the
patch, the above code will collapse to a single append call:

      preservedData_.append(aBuf);


HTH,

Alex.
P.S. AFAICT, there is no guarantee that SBuf using GetStorePrototype()
isEmpty so checking both conditions seems necessary to me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: faster-append-t2.patch
Type: text/x-diff
Size: 1653 bytes
Desc: not available
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20161006/42791e44/attachment-0001.patch>


More information about the squid-dev mailing list