I was wondering something regarding lenses. Should I define a lens such as this: ``` Body.auto<Re...
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