I was wondering something regarding lenses. Should...
# http4k
r
I was wondering something regarding lenses. Should I define a lens such as this:
Copy code
Body.auto<RequestBody>().toLens()
Once as a constant and use it inside of other methods? Or write it inside of a method? I guess what i’m asking if it will be recreated every time in the method with no reason :x
1
d
You can do either - we tend to (inconsistently) define them as constants so they can be reused easily - but TBH I suspect that recreating them every time would have a negligible effect in the grand scheme of things
👍 1
r
I’m a bit anal about performance 😄
d
then measure it and let us know! 😉
1
but yes - sharing the instance is our preferred mechanic
and also, the JVM is really good at optimising hot code paths, so you might find that it makes less difference over time
👍 1
r
Sorry dave, I’m so swamped at work I don’t even have time to run these tests, but once things calm down I’ll be using http4k in my personal project and bench mark it and share 😄
👍 1