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
dave
10/16/2019, 8:21 AM
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
Razi Kheir
10/16/2019, 8:46 AM
Iโm a bit anal about performance ๐
d
dave
10/16/2019, 8:46 AM
then measure it and let us know! ๐
โ 1
dave
10/16/2019, 8:47 AM
but yes - sharing the instance is our preferred mechanic
dave
10/16/2019, 8:47 AM
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
Razi Kheir
10/21/2019, 5:56 AM
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 ๐