Skip to content

Commit

Permalink
Use WeakHashMap to store window keys
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Jul 3, 2023
1 parent 492cbe8 commit d22aeed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.metrics.performance.FrameData
import androidx.metrics.performance.JankStats
import com.datadog.android.v2.api.InternalLogger
import java.lang.ref.WeakReference
import java.util.WeakHashMap
import java.util.concurrent.TimeUnit

/**
Expand All @@ -26,8 +27,8 @@ internal class JankStatsActivityLifecycleListener(
private val jankStatsProvider: JankStatsProvider = JankStatsProvider.DEFAULT
) : ActivityLifecycleCallbacks, JankStats.OnFrameListener {

private val activeWindowsListener = mutableMapOf<Window, JankStats>()
private val activeActivities = mutableMapOf<Window, MutableList<WeakReference<Activity>>>()
private val activeWindowsListener = WeakHashMap<Window, JankStats>()
private val activeActivities = WeakHashMap<Window, MutableList<WeakReference<Activity>>>()

// region ActivityLifecycleCallbacks
@MainThread
Expand Down
2 changes: 1 addition & 1 deletion detekt_custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ datadog:
- "kotlin.collections.List.toSet()"
- "kotlin.collections.List.withIndex()"
- "kotlin.collections.Map.containsKey(kotlin.String)"
- "kotlin.collections.MutableMap.containsKey(android.view.Window)"
- "kotlin.collections.Map.filter(kotlin.Function1)"
- "kotlin.collections.Map.filterKeys(kotlin.Function1)"
- "kotlin.collections.Map.filterValues(kotlin.Function1)"
Expand Down Expand Up @@ -671,6 +670,7 @@ datadog:
- "kotlin.collections.MutableList?.firstOrNull(kotlin.Function1)"
- "kotlin.collections.MutableMap.clear()"
- "kotlin.collections.MutableMap.containsKey(kotlin.Long)"
- "kotlin.collections.MutableMap.containsKey(android.view.Window)"
- "kotlin.collections.MutableMap.filterKeys(kotlin.Function1)"
- "kotlin.collections.MutableMap.forEach(kotlin.Function1)"
- "kotlin.collections.MutableMap?.forEach(kotlin.Function1)"
Expand Down

0 comments on commit d22aeed

Please sign in to comment.