Check queue size before starting Animated batch

Summary:
Small win: if the queue is empty we shouldn't start/stop the batch.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D36298399

fbshipit-source-id: b43c07994ba28b4c890fe52af4e81c265a3b8ac7
This commit is contained in:
Pieter De Baets
2022-05-12 05:49:01 -07:00
committed by Facebook GitHub Bot
parent 2c5a966054
commit 55ee8ce0c4
+12 -10
View File
@@ -65,16 +65,18 @@ const API = {
},
disableQueue: function (): void {
invariant(NativeAnimatedModule, 'Native animated module is not available');
if (Platform.OS === 'android') {
NativeAnimatedModule.startOperationBatch();
}
for (let q = 0, l = queue.length; q < l; q++) {
queue[q]();
}
queue.length = 0;
if (Platform.OS === 'android') {
NativeAnimatedModule.finishOperationBatch();
const queueLength = queue.length;
if (queueLength > 0) {
if (Platform.OS === 'android') {
NativeAnimatedModule.startOperationBatch();
}
for (let i = 0; i < queueLength; i++) {
queue[i]();
}
queue.length = 0;
if (Platform.OS === 'android') {
NativeAnimatedModule.finishOperationBatch();
}
}
},
queueOperation: (fn: () => void): void => {