HurricaneJames / react-immutable-proptypes

PropType validators that work with Immutable.js.
MIT License
642 stars 46 forks source link

Defer performance-intensive error message generation until needed #32

Closed jsdf closed 8 years ago

jsdf commented 8 years ago

getPropType has poor time complexity as it calls .toSource which serialises the entire Immutable data structure, and in some of the checkers this function is being unnecessarily called, even when no error has occured. As the data structure being checked grows large this can very noticeably slow down rendering (in development, at least). This PR moves calls to getPropType in the Record and Shape checkers so it is only called in an error case.

Ideally the implementation of getPropType wouldn't call .toSource but I couldn't easily come up with an alternative which works for all data structures, for all versions of immutable-js (something for another PR perhaps).