luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.57k stars 156 forks source link

Refactor RequestBodyReader #1826

Closed jwoertink closed 10 months ago

jwoertink commented 10 months ago

Purpose

Fixes #1825

Description

The original implementation of this was a bit difficult to read and understand. This is just a refactor to make the intention of the method a little easier to comprehend. Added some docs.

Also ran some benchmarks and this way is slightly faster:

old  11.59k ( 86.27µs) (± 1.24%)  578kB/op   1.45× slower
new  16.75k ( 59.70µs) (± 0.75%)  406kB/op        fastest

Checklist