fireship-io / flamethrower

A blazingly fast router for static sites
MIT License
2.79k stars 109 forks source link

⚡ Performance Optimisations #28

Closed ekwoka closed 2 years ago

ekwoka commented 2 years ago

This PR:

This algorithm, while adding about 200bytes to the minzipped size, should improve performance with a focus on the main setup a website should have: head elements that may be numerous in number, are generally laid out in the same order with limited difference.

This, in a happy scenario (no changes) does one comparison for child of the head. Total comparisons should be something like #matchingNodes + 2(#staleNodes * #freshNodes), which should be improved over the old algorithm comparison count of n! for even the happy path.

codediodeio commented 2 years ago

Nice! Thank you