Make Style Interpolator Function Generation Lazy
Summary: This code generation executes eagerly and these functions are fairly large and takes time to compile. However, I'm mostly doing this change because it significantly increases the Prepack binary file size. In theory, there might be a slight impact on the first use of these interpolators but I couldn't really tell. An alternative would be to create a factory that is called by the components at an appropriate time, or to just refactor the whole thing to use Animated. I didn't want to dig too deeply for a single component though. public Reviewed By: vjeux Differential Revision: D2687296 fb-gh-sync-id: 6fc8cdf54dfb6f0b50c11db973d67d114bbc7400
This commit is contained in:
parent
598d37f6d5
commit
f624d01cac
|
@ -553,8 +553,15 @@ var createFunctionString = function(anims) {
|
|||
* object and returns a boolean describing if any update was actually applied.
|
||||
*/
|
||||
var buildStyleInterpolator = function(anims) {
|
||||
return Function(createFunctionString(anims))();
|
||||
// Defer compiling this method until we really need it.
|
||||
var interpolator = null;
|
||||
function lazyStyleInterpolator(result, value) {
|
||||
if (interpolator === null) {
|
||||
interpolator = Function(createFunctionString(anims))();
|
||||
}
|
||||
return interpolator(result, value);
|
||||
}
|
||||
return lazyStyleInterpolator;
|
||||
};
|
||||
|
||||
|
||||
module.exports = buildStyleInterpolator;
|
||||
|
|
Loading…
Reference in New Issue