Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance? #15

Open
sleeyax opened this issue Jun 16, 2023 · 0 comments
Open

Performance? #15

sleeyax opened this issue Jun 16, 2023 · 0 comments

Comments

@sleeyax
Copy link

sleeyax commented Jun 16, 2023

What's the performance of this library? Do you plan to add any benchmarks?

On first sight there appears to be a longer startup time with this library vs a custom platform-specific implementation, but maybe I'm doing something wrong. Thus, some more information about performance would clear things up for me (and many others)!

Click to see example

Example custom implementation w/o this lib

This is what my setup looked like without this library.

commonMain/.../L18n.kt:

@Composable
@ReadOnlyComposable
expect fun translate(key: String): String

androidMain/.../L18n.kt:

package com.example.common.platform

import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.res.stringResource
import com.example.common.R

@ReadOnlyComposable
@Composable
actual fun translate(key: String): String {
    val stringClass = R.string::class.java
    val field = stringClass.getDeclaredField(key)
    return stringResource(field.get(stringClass) as Int)
}

iosMain/.../L18n.kt:

Not implemented yet, but same principle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant