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

Avoid usage of forEach on ranges. #50

Open
JedS6391 opened this issue Nov 17, 2018 · 0 comments
Open

Avoid usage of forEach on ranges. #50

JedS6391 opened this issue Nov 17, 2018 · 0 comments

Comments

@JedS6391
Copy link
Owner

There are a few places where the following syntax is used in the system:

(0..n).forEach {
    // Do something
}

According to this article, forEach is 300% slower than a for-loop and should be avoided.

A grep on the source code identified the following occurrences:

src//main/kotlin/lgp/core/evolution/operators/SelectionOperator.kt:    (0..tournamentSize - 2).forEach { _ ->
src/main/kotlin/lgp/core/evolution/model/Models.kt:                    (0 until this.environment.configuration.generations).forEach { gen ->
src/main/kotlin/lgp/core/evolution/model/Models.kt:                    (0 until this.environment.configuration.generations).forEach { gen ->
src/main/kotlin/lgp/core/evolution/model/Models.kt:                    (0 until numGenerations).forEach { _ ->
src/main/kotlin/lgp/core/evolution/model/Models.kt:                    (0 until this@IslandMigration.options.migrationSize).forEach { _ ->
src/main/kotlin/lgp/core/program/registers/RegisterSet.kt:             (0 until this.totalRegisters).forEach { r ->
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