Skip to content

Commit

Permalink
Remove the todo to recommend Streaming Parsing
Browse files Browse the repository at this point in the history
The performance improvement is not much, and we are using `decodeFromStream` so it works
  • Loading branch information
Iamlooker committed Aug 21, 2024
1 parent 4df61e6 commit 09f7d20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.looker.sync.fdroid.v1.model.AppV1
import com.looker.sync.fdroid.v1.model.IndexV1
import com.looker.sync.fdroid.v1.model.Localized
import com.looker.sync.fdroid.v1.model.PackageV1
import com.looker.sync.fdroid.v1.model.PermissionV1
import com.looker.sync.fdroid.v1.model.RepoV1
import com.looker.sync.fdroid.v2.model.AntiFeatureV2
import com.looker.sync.fdroid.v2.model.CategoryV2
Expand Down Expand Up @@ -172,8 +171,8 @@ private fun PackageV1.toVersionV2(
usesSdk = sdkV2(),
minSdkVersion = minSdkVersion,
maxSdkVersion = maxSdkVersion,
usesPermission = usesPermission.toV2(),
usesPermissionSdk23 = usesPermission23.toV2(),
usesPermission = usesPermission.map { PermissionV2(it.name, it.maxSdk) },
usesPermissionSdk23 = usesPermission23.map { PermissionV2(it.name, it.maxSdk) },
features = features?.map { FeatureV2(it) } ?: emptyList(),
nativecode = nativeCode ?: emptyList()
),
Expand All @@ -190,8 +189,6 @@ private fun PackageV1.sdkV2(): UsesSdkV2? {
}
}

private fun List<PermissionV1>.toV2(): List<PermissionV2> = map { PermissionV2(it.name, it.maxSdk) }

private inline fun Map<String, Localized>.localizedString(
default: String?,
crossinline block: (Localized) -> String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ class V1ParserTest {
private val v2JsonFile = getResource("izzy_index_v2.json")
private val repo = Izzy

/**
* Use jackson's streaming api to parse json's
* https://www.baeldung.com/jackson-streaming-api
* https://github.com/FasterXML/jackson-docs/wiki/JacksonStreamingApi
*/
@Test
fun `parse v1 json and compare with v2`() = runTest(dispatcher) {
requireNotNull(jarFile)
Expand All @@ -65,7 +60,7 @@ class V1ParserTest {
}
}

private inline fun memory(
internal inline fun memory(
block: () -> Unit,
) {
val runtime = Runtime.getRuntime()
Expand Down

0 comments on commit 09f7d20

Please sign in to comment.