Pre-allocate storage in http2::HuffmanEncode().
Also, do not call http2::HuffmanEncode() in
QpackInstructionEncoder::DoStartString() if it does not result in size savings.
Note that performance gets worse for short strings, presumably because
std::string::reserve() for small values is a no-op due to small string
optimization. However, I plan to modify http2::HuffmanEncode() not to clear the
output string and modify QpackInstructionEncoder to avoid copying, which should
result in a performance improvement overall.
Also I'll add a slightly faster implementation in the next CL, so this is really
only to change the API to make tests simpler.
PiperOrigin-RevId: 334909897
Change-Id: Idd7414c0dcaa56fc62d0822ec06250d480d2972c
6 files changed