orika-mapper/orika

Minimize same getter calls

porunov opened this issue · 0 comments

During mapping we call getters multiple times. For different situations I see different amount of getter calls (2-5 calls for a single field).
I case our getter has slow computation (for example, database calls, or generally complex logic) it may cause additional delays which could be omitted if we would call a getter only once.
Other possible problem which could be is unnecessary or unpredicted computation (for example, if we change something between each call of the getter method).
To mitigate this issue I would propose minimize getter calls (ideally we should call a getter only once, if it is needed).
A possible solution, could be making a variables for each mapping field of source object and destination object (optionally). After that we could use created variables instead of calling getters to retrieve the value.