Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️Refactor: Simplify content negotiation code (#2865)
* refactor: Update to use fasthttp.VisitHeaderParams The implementation of forEachParameter was upstreamed to fasthttp, so use that version instead of maintaining our own. * refactor: use map for header params The previous implementation of content negotiation used some difficult to understand techniques in order to reduce allocations, potentially hurting maintainability. The more natural approach for storing and comparing unordered media-type parameters is to utilize maps. While the resulting code still isn't as simple as it could be, it's a step closer. To reduce allocations, we use a sync.Pool. This actually reduces in fewer allocations than before at 3 or more parameters. The net result is nearly identical performance for zero parameters, almost-as-good performance for 1-2 parameters, and better performance for 3+ parameters. --------- Co-authored-by: Jason McNeil <sixcolors@mac.com>
- Loading branch information