[squid-dev] Idea: what if SBuf was a Packable?

Alex Rousskov rousskov at measurement-factory.com
Wed Mar 13 13:08:02 UTC 2024


On 2024-03-13 05:25, Francesco Chemolli wrote:

>    I spent some time wondering whether we could reduce
> code duplication by making SBuf implement the Packable interface,
> and replacing SBufStream with PackableStream.

This idea was studied two years ago, including spending many hours on 
discussing virtualization costs and building specific examples to 
illustrate those costs. You have participated.

https://github.com/squid-cache/squid/pull/932

I also suspect that "code duplication" you are wondering about either 
does not exist or is not related to the suggested changes: SBufStream 
code does not duplicate much, and moving its functionality to SBuf will 
_move_ unique code, not REmove it.

If you want to continue in this overall direction, I suggest identifying 
a specific use case (the simplest one you can find) that illustrates 
code duplication that should not be resolved by other means.


HTH,

Alex.


> The interface changes seem rather minimal, SBuf already implements
> append(const char*, int) and vappendf; the main difference there is
> that SBuf returns *this.
> These methods are of course virtual, which is a price to pay, but besides
> the vtbl size, maybe there is a way to not pay their cost when not used
> 
> What do you think?
> 
> -- 
>      Francesco
> 
> _______________________________________________
> squid-dev mailing list
> squid-dev at lists.squid-cache.org
> https://lists.squid-cache.org/listinfo/squid-dev



More information about the squid-dev mailing list