Building a StructMap is an expensive operation but fortunately there
is a cache for that inside reflectx's Mapper struct. Unfortunately we
were not using it because for every ResourceToMap call we created a
new mapper instance. This commit changes that to always use one global
mapper instance.
It's hard to measure exact performance improvements for ResourceToMap
run times, because they vary depending on how complex input objects
were. We might say that it is now a couple of times faster. What's
more, our project based on gohan, sees 20% runtime improvement when
running all tests, just because this one function is heavily used
there.
Building a StructMap is an expensive operation but fortunately there is a cache for that inside reflectx's Mapper struct. Unfortunately we were not using it because for every ResourceToMap call we created a new mapper instance. This commit changes that to always use one global mapper instance.
It's hard to measure exact performance improvements for ResourceToMap run times, because they vary depending on how complex input objects were. We might say that it is now a couple of times faster. What's more, our project based on gohan, sees 20% runtime improvement when running all tests, just because this one function is heavily used there.
Removed unused Clone method while at it.