Revert "Improve performance of encodeHeader"

This reverts commit 240641a3934cd2eb5f98c4591ddbef2e98ad0254.
Revert "Revert "Improve performance of encodeHeader""

This reverts commit fce111028962651f825b87d3375b325da6034bea.
Revert "Revert "Revert "Improve performance of encodeHeader"""

This reverts commit 3f4bfd1e0d21a5030ec891eb7fe9d87a7b3ee037.
Revert "Revert "Revert "Revert "Improve performance of encodeHeader""""

This reverts commit f5cfb4433676ac58805d3ee4f848d2b643cda861.