Skip to content

Commit

Permalink
Check queue size before starting Animated batch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javache authored and facebook-github-bot committed May 12, 2022
1 parent 2c5a966 commit 55ee8ce
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 55ee8ce

Please sign in to comment.