I noticed that Encoding::from_headers unnecessarily allocates a Vec for all the supported encodings it finds before selecting the most suitable one of them.
Solution
Change encodings to return an iterator and only collect that iterator where it makes sense.
Motivation
I noticed that
Encoding::from_headers
unnecessarily allocates aVec
for all the supported encodings it finds before selecting the most suitable one of them.Solution
Change
encodings
to return an iterator and only collect that iterator where it makes sense.