-
-
Notifications
You must be signed in to change notification settings - Fork 718
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
flatten: use loop and ArrayDeque instead of recursion #1801
flatten: use loop and ArrayDeque instead of recursion #1801
Conversation
Could run some benchmark test to try to ensure we don't reproduce the same @hoc081098 ? 🙏 |
Yes, I will add it 😊 |
@arnaudgiuliani I have added some benchmarks.
Could you check it again 🙏 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job. I was planning to take on this issue, but you were faster! Your implementation is exactly what I had in mind, so thank you for contributing with the improvement.
} | ||
|
||
@OptIn(KoinInternalApi::class) | ||
internal fun newFlatten(modules: List<Module>): Set<Module> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: can't you use the original function here instead of duplicating it?
projects/core/koin-core/src/commonMain/kotlin/org/koin/core/module/Module.kt
Outdated
Show resolved
Hide resolved
projects/core/koin-core/src/commonMain/kotlin/org/koin/core/module/Module.kt
Outdated
Show resolved
Hide resolved
projects/core/koin-core/src/commonMain/kotlin/org/koin/core/module/Module.kt
Outdated
Show resolved
Hide resolved
Good work. I need to redirect it on 3.6 branch ... will do a merge from main to 3.6 |
macos tests are fixed in another branch |
examples/jvm-perfs/src/main/kotlin/org/koin/benchmark/nestedModules.kt
Outdated
Show resolved
Hide resolved
examples/jvm-perfs/src/main/kotlin/org/koin/benchmark/nestedModules.kt
Outdated
Show resolved
Hide resolved
@arnaudgiuliani Should I change target branch to 3.6? |
:pray |
projects/core/koin-core/src/commonMain/kotlin/org/koin/core/module/Module.kt
Outdated
Show resolved
Hide resolved
examples/jvm-perfs/src/main/kotlin/org/koin/benchmark/nestedModules.kt
Outdated
Show resolved
Hide resolved
@arnaudgiuliani please review it again 🙏 |
…081098-patch-1
@hoc081098 The optimization is really great but we have an issue as, the returned result can randomly not be in the same order as the module list. flatten(m1, m2) can result in <m1,m2> or <m1,m2> which is breaking capacity to overload a definition, given the module order |
|
@arnaudgiuliani |
I think so, linkedhashmap is better than not.
Vào 9:22 Th 6, 5 thg 4, 2024 Petrus Nguyễn Thái Học <
***@***.***> đã viết:
… DefinitionOverrideTest is failing on branch 3.6.0
I think because I have used HashMap, I will create a PR to fix it
—
Reply to this email directly, view it on GitHub
<#1801 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMNXWG25SEWZA6WWKEECBIDY3YDIFAVCNFSM6AAAAABEBBFOQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZYGY2DAOJUGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
@arnaudgiuliani please review PR #1841. |
maybe fix #1794