Use some core ktx
This commit is contained in:
parent
e633da5567
commit
d7eac12eee
@ -2,6 +2,7 @@ package exh.eh
|
|||||||
|
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import androidx.core.util.AtomicFile
|
import androidx.core.util.AtomicFile
|
||||||
|
import androidx.core.util.forEach
|
||||||
import com.elvishew.xlog.XLog
|
import com.elvishew.xlog.XLog
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -128,10 +129,9 @@ class MemAutoFlushingLookupTable<T>(
|
|||||||
val fos = atomicFile.startWrite()
|
val fos = atomicFile.startWrite()
|
||||||
try {
|
try {
|
||||||
val out = fos.buffered()
|
val out = fos.buffered()
|
||||||
for (i in 0 until table.size()) {
|
table.forEach { key, value ->
|
||||||
val k = table.keyAt(i)
|
val v = serializer.write(value).toByteArray(Charsets.UTF_8)
|
||||||
val v = serializer.write(table.valueAt(i)).toByteArray(Charsets.UTF_8)
|
bb.putInt(0, key)
|
||||||
bb.putInt(0, k)
|
|
||||||
bb.putInt(4, v.size)
|
bb.putInt(4, v.size)
|
||||||
out.write(bb.array())
|
out.write(bb.array())
|
||||||
out.write(v)
|
out.write(v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user