Skip to content

Commit

Permalink
Delete LongArray (#45736)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed Aug 12, 2024
1 parent 010e001 commit 471445e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 133 deletions.
10 changes: 0 additions & 10 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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
Expand Down Expand Up @@ -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 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: 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 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)
}
}

0 comments on commit 471445e

Please sign in to comment.