Closed Thomasdezeeuw closed 8 years ago
This still looks like the index is getting calculated on every request as poolIndex
is still being called within the middleware handler. If anything, this is causing the function to be called more often than it would need to be as it no longer is part of the lazy init block.
Have you run benchmarks to check if there are any significant improvements?
I'll change when the index is calculated to when the function is first called and will add some benchmarks.
Could you also please provide some context as to the reasoning behind this change?
The main reason behind the change is to not calculate the pool index on every request, but only when NewGzipLevelHandler is called. This increase the performance a little bit, see the benchmarks in the commit.
It looks like the latest commit you've pushed does what you're looking for as it now calls poolIndex
outside of the http.HandlerFunc
returned by the construct.
Now you just need to clean up the rename from level
=> index
to get the tests to pass.
The commits are a bit messed up, but when I try to squash them it messes up the code. This is what happened the first time, that's why I pushed broken code.
This looks better, thanks! I'll deal with squashing the commits via the merge button.
:tada: 💯
Thanks
This removes the need to calculate the index on every request.