From 9342f25d5fcb91c9f2951445dcc853a48e26ceb6 Mon Sep 17 00:00:00 2001 From: Alex Dvornikov Date: Mon, 24 Jul 2017 07:09:41 -0700 Subject: [PATCH] Inline requires in JSTimers Reviewed By: javache Differential Revision: D5466322 fbshipit-source-id: 0bcc71e19cdb48d95b5e35ae2f720d46baf9bb50 --- Libraries/Core/Timers/JSTimers.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index e2bca9fb2..73b6c1235 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -16,13 +16,18 @@ const Platform = require('Platform'); const Systrace = require('Systrace'); const invariant = require('fbjs/lib/invariant'); -const performanceNow = require('fbjs/lib/performanceNow'); -const warning = require('fbjs/lib/warning'); - const {Timing} = require('NativeModules'); import type {ExtendedError} from 'parseErrorStack'; +let _performanceNow = null; +function performanceNow() { + if (!_performanceNow) { + _performanceNow = require('fbjs/lib/performanceNow'); + } + return _performanceNow(); +} + /** * JS implementation of timer functions. Must be completely driven by an * external clock signal, all that's stored here is timerID, timer type, and @@ -96,7 +101,7 @@ function _allocateCallback(func: Function, type: JSTimerType): number { * recurring (setInterval). */ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) { - warning( + require('fbjs/lib/warning')( timerID <= GUID, 'Tried to call timer with ID %s but no such timer exists.', timerID,