mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Delete LongArray (#45736)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45736 This was an internally used class that was made irrelevant by Kotlin conversion. Appears to be unused in OSS, no breakages expected. Changelog: [Android][Breaking] - Deleted LongArray Reviewed By: sammy-SC Differential Revision: D60292651 fbshipit-source-id: cebb3d41113ad9f3247c3189889337d6e3e4ebab
This commit is contained in:
committed by
Facebook GitHub Bot
parent
010e0010a3
commit
471445eb17
@@ -1798,16 +1798,6 @@ public final class com/facebook/react/common/LifecycleState : java/lang/Enum {
|
||||
public static fun values ()[Lcom/facebook/react/common/LifecycleState;
|
||||
}
|
||||
|
||||
public class com/facebook/react/common/LongArray {
|
||||
public fun add (J)V
|
||||
public static fun createWithInitialCapacity (I)Lcom/facebook/react/common/LongArray;
|
||||
public fun dropTail (I)V
|
||||
public fun get (I)J
|
||||
public fun isEmpty ()Z
|
||||
public fun set (IJ)V
|
||||
public fun size ()I
|
||||
}
|
||||
|
||||
public class com/facebook/react/common/MapBuilder {
|
||||
public fun <init> ()V
|
||||
public static fun builder ()Lcom/facebook/react/common/MapBuilder$Builder;
|
||||
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.common;
|
||||
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
|
||||
/** Object wrapping an auto-expanding long[]. Like an ArrayList<Long> but without the autoboxing. */
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public class LongArray {
|
||||
|
||||
private static final double INNER_ARRAY_GROWTH_FACTOR = 1.8;
|
||||
|
||||
private long[] mArray;
|
||||
private int mLength;
|
||||
|
||||
public static LongArray createWithInitialCapacity(int initialCapacity) {
|
||||
return new LongArray(initialCapacity);
|
||||
}
|
||||
|
||||
private LongArray(int initialCapacity) {
|
||||
mArray = new long[initialCapacity];
|
||||
mLength = 0;
|
||||
}
|
||||
|
||||
public void add(long value) {
|
||||
growArrayIfNeeded();
|
||||
mArray[mLength++] = value;
|
||||
}
|
||||
|
||||
public long get(int index) {
|
||||
if (index >= mLength) {
|
||||
throw new IndexOutOfBoundsException("" + index + " >= " + mLength);
|
||||
}
|
||||
return mArray[index];
|
||||
}
|
||||
|
||||
public void set(int index, long value) {
|
||||
if (index >= mLength) {
|
||||
throw new IndexOutOfBoundsException("" + index + " >= " + mLength);
|
||||
}
|
||||
mArray[index] = value;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return mLength;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return mLength == 0;
|
||||
}
|
||||
|
||||
/** Removes the *last* n items of the array all at once. */
|
||||
public void dropTail(int n) {
|
||||
if (n > mLength) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"Trying to drop " + n + " items from array of length " + mLength);
|
||||
}
|
||||
mLength -= n;
|
||||
}
|
||||
|
||||
private void growArrayIfNeeded() {
|
||||
if (mLength == mArray.length) {
|
||||
// If the initial capacity was 1 we need to ensure it at least grows by 1.
|
||||
int newSize = Math.max(mLength + 1, (int) (mLength * INNER_ARRAY_GROWTH_FACTOR));
|
||||
long[] newArray = new long[newSize];
|
||||
System.arraycopy(mArray, 0, newArray, 0, mLength);
|
||||
mArray = newArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
-50
@@ -8,7 +8,6 @@
|
||||
package com.facebook.react.modules.debug
|
||||
|
||||
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener
|
||||
import com.facebook.react.common.LongArray
|
||||
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener
|
||||
|
||||
/**
|
||||
@@ -19,10 +18,10 @@ import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugL
|
||||
*/
|
||||
internal class DidJSUpdateUiDuringFrameDetector :
|
||||
NotThreadSafeBridgeIdleDebugListener, NotThreadSafeViewHierarchyUpdateDebugListener {
|
||||
private val transitionToIdleEvents = LongArray.createWithInitialCapacity(20)
|
||||
private val transitionToBusyEvents = LongArray.createWithInitialCapacity(20)
|
||||
private val viewHierarchyUpdateEnqueuedEvents = LongArray.createWithInitialCapacity(20)
|
||||
private val viewHierarchyUpdateFinishedEvents = LongArray.createWithInitialCapacity(20)
|
||||
private val transitionToIdleEvents = ArrayList<Long>(20)
|
||||
private val transitionToBusyEvents = ArrayList<Long>(20)
|
||||
private val viewHierarchyUpdateEnqueuedEvents = ArrayList<Long>(20)
|
||||
private val viewHierarchyUpdateFinishedEvents = ArrayList<Long>(20)
|
||||
@Volatile private var wasIdleAtEndOfLastFrame = true
|
||||
|
||||
@Synchronized
|
||||
@@ -106,53 +105,42 @@ internal class DidJSUpdateUiDuringFrameDetector :
|
||||
wasIdleAtEndOfLastFrame
|
||||
} else lastIdleTransition > lastBusyTransition
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun hasEventBetweenTimestamps(
|
||||
eventArray: LongArray,
|
||||
startTime: Long,
|
||||
endTime: Long
|
||||
): Boolean {
|
||||
for (i in 0 until eventArray.size()) {
|
||||
val time = eventArray[i]
|
||||
if (time in startTime until endTime) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
private fun hasEventBetweenTimestamps(
|
||||
eventArray: ArrayList<Long>,
|
||||
startTime: Long,
|
||||
endTime: Long
|
||||
): Boolean = eventArray.any { time -> time in startTime until endTime }
|
||||
|
||||
private fun getLastEventBetweenTimestamps(
|
||||
eventArray: LongArray,
|
||||
startTime: Long,
|
||||
endTime: Long
|
||||
): Long {
|
||||
var lastEvent: Long = -1
|
||||
for (i in 0 until eventArray.size()) {
|
||||
val time = eventArray[i]
|
||||
if (time in startTime until endTime) {
|
||||
lastEvent = time
|
||||
} else if (time >= endTime) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return lastEvent
|
||||
}
|
||||
|
||||
private fun cleanUp(eventArray: LongArray, endTime: Long) {
|
||||
val size = eventArray.size()
|
||||
var indicesToRemove = 0
|
||||
for (i in 0 until size) {
|
||||
if (eventArray[i] < endTime) {
|
||||
indicesToRemove++
|
||||
}
|
||||
}
|
||||
if (indicesToRemove > 0) {
|
||||
for (i in 0 until size - indicesToRemove) {
|
||||
eventArray[i] = eventArray[i + indicesToRemove]
|
||||
}
|
||||
eventArray.dropTail(indicesToRemove)
|
||||
}
|
||||
private fun getLastEventBetweenTimestamps(
|
||||
eventArray: ArrayList<Long>,
|
||||
startTime: Long,
|
||||
endTime: Long
|
||||
): Long {
|
||||
var lastEvent: Long = -1
|
||||
for (time in eventArray) {
|
||||
if (time in startTime until endTime) {
|
||||
lastEvent = time
|
||||
} else if (time >= endTime) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return lastEvent
|
||||
}
|
||||
|
||||
private fun cleanUp(eventArray: ArrayList<Long>, endTime: Long) {
|
||||
val size = eventArray.size
|
||||
var indicesToRemove = 0
|
||||
for (i in 0 until size) {
|
||||
if (eventArray[i] < endTime) {
|
||||
indicesToRemove++
|
||||
}
|
||||
}
|
||||
if (indicesToRemove > 0) {
|
||||
for (i in 0 until size - indicesToRemove) {
|
||||
eventArray[i] = eventArray[i + indicesToRemove]
|
||||
}
|
||||
eventArray.dropLast(indicesToRemove)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user