mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Avoid allocating empty lists
Summary: Changelog: [Internal] Optimize Fabric memory allocations on Android Reviewed By: genkikondo Differential Revision: D36098912 fbshipit-source-id: 8d34a652db019865a8306bc070a08f5ddfef96bf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b9bb30b1ad
commit
5de0f145ec
+5
-2
@@ -356,13 +356,16 @@ public class MountItemDispatcher {
|
||||
@Nullable
|
||||
private static <E extends MountItem> List<E> drainConcurrentItemQueue(
|
||||
ConcurrentLinkedQueue<E> queue) {
|
||||
if (queue.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<E> result = new ArrayList<>();
|
||||
while (!queue.isEmpty()) {
|
||||
do {
|
||||
E item = queue.poll();
|
||||
if (item != null) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
} while (!queue.isEmpty());
|
||||
if (result.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user