-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Enhancement] Lazy properties in code output #63
Comments
Hello, thanks for idea 🙂 One point, I think better to add val ArrowLeft: ImageVector by lazy(LazyThreadSafetyMode.NONE) {
ImageVector.Builder(....).build()
} |
Even better, looking forward to it! |
Will keep open to track progress 🙂 |
I believe this is not ideal because lazy init will increase memory consumption by keeping a reference to the initializer and the lazy property delegate wrapper that in this case will serve no purpose other than looking pretty. If Google wanted to use lazy for their icons, they would have already done that, but they didn't. |
Yes, it is one of the reason why backing property is default output in plugin 🙂 |
@vladmircan feature implemented in latest nightly build: https://github.com/ComposeGears/Valkyrie/releases/tag/Nightly |
@egorikftp It works, great job! Love that you added a toggle to choose between code outputs. |
GPT has other opinion about lazy block: Memory Differences AnalysisMemory Overhead:
The actual memory difference between these approaches is likely minimal and may not significantly impact performance, especially if the initialization code is lightweight and the application doesn't heavily rely on these icons. Conclusions:
|
@egorikftp Something to be aware of for sure, thanks for posting the analysis! |
GPT is not entirely correct. At this point this discussion is mostly nitpicking and overengineering, but I think the best solution is to just let the user choose the approach they want to use. |
Will close issue as completed in 0.5.0 release https://github.com/ComposeGears/Valkyrie/releases/tag/Valkyrie-0.5.0 |
Description
Instead of generating a
custom
singleton pattern for every icon, we could use thebuilt-in
lazy functionality.For example:
becomes
A minor thing to be sure but it does:
8 / per file
which across something like300
icons becomes significantP.S. Love the plugin!
The text was updated successfully, but these errors were encountered: