felixblaschke / shelf_plus

MIT License
73 stars 14 forks source link

Early return when checking toJson invoke in List items #3

Closed davidmartos96 closed 3 years ago

davidmartos96 commented 3 years ago

Hey there! I was looking at the new feature you've added for handling list responses as json and I saw that the code tries to run toJson on all items in the list even if the any of them doesn't match. This change may be negligible in terms of performance, but maybe it could add up with bigger lists and many requests. Every failure involves a dynamic method call, a try catch and a String contains.

Before: image

After: image

Let me know what you think. Thanks for the work on the package!

felixblaschke commented 3 years ago

Returning early totally makes sense :-)

Thank you for the contribution.