mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix CollectionSizeUse and UnsafeDereference lint warnings (#55442)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55442 Fixed lint warnings in LongStreamingStats.kt: - Replaced `size == 0` with `isEmpty()` for better readability - Replaced `!!` operator with safe null handling using `?: 0L` changelog: [internal] internal Reviewed By: javache Differential Revision: D91844147 fbshipit-source-id: c6376ed09b6b07da9c2e291c7ec33980d16dafc0
This commit is contained in:
1 parent
bf3b2207d1
commit
f0062401ff
1 file changed
+2
-2
+2
-2
@@ -49,14 +49,14 @@ internal class LongStreamingStats {
|
||||
|
||||
val median: Double
|
||||
get() {
|
||||
if (minHeap.size == 0 && maxHeap.size == 0) {
|
||||
if (minHeap.isEmpty() && maxHeap.isEmpty()) {
|
||||
return 0.0
|
||||
}
|
||||
val median =
|
||||
if (minHeap.size > maxHeap.size) {
|
||||
minHeap.peek()
|
||||
} else {
|
||||
(minHeap.peek() ?: 0 + maxHeap.peek()!!) / 2
|
||||
((minHeap.peek() ?: 0L) + (maxHeap.peek() ?: 0L)) / 2
|
||||
}
|
||||
return median.toDouble()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user