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

[Maintenance] performance forEach on range #1992

Conversation

GrzegorzBobryk
Copy link
Contributor

First one will create Iterator object, second will not. It was used like that only in tests. But gaining slightly faster tests is also good in my opinion.

GrzegorzBobryk and others added 2 commits October 27, 2024 21:26
- `forEach` function [Performs the given operation on each element of this Iterator.](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/for-each.html).
- `for` loop [A for loop over a range or an array is compiled to an index-based loop that does not create an iterator object.](https://kotlinlang.org/docs/control-flow.html#for-loops)

First one will create `Iterator` object, second will not. It was used like that only in tests. But gaining slightly faster tests is good in my opinion.
@GrzegorzBobryk GrzegorzBobryk force-pushed the maintenance/performance-forEach-on-range branch from 4eb1548 to 5de2c7f Compare October 27, 2024 20:35
@arnaudgiuliani arnaudgiuliani changed the base branch from main to 4.0.1 November 6, 2024 16:27
@arnaudgiuliani arnaudgiuliani merged commit 1ec7cfe into InsertKoinIO:4.0.1 Nov 15, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants