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

Remove redundant array initializers #225

Merged
merged 1 commit into from
Sep 21, 2021

Conversation

juliabeliaeva
Copy link
Contributor

There is a number of places in the code where the following pattern is used:

val array = Array(length) { /*initializer*/ }
for ( i in 0 until length) {
  array[i] = /*other initializer*/
}

Sometimes the first initializer creates another array, which is then thrown out in the for-cycle.
This commit fixes such places in the code.

@zaleslaw
Copy link
Collaborator

Yeah, there are a few places in the ancient code. When I made the first steps with the Kotlin Arrays and code practices, thanks for fixing it, I just blindly copy-pasted the old code into the new one.

@zaleslaw zaleslaw merged commit f5190a3 into Kotlin:master Sep 21, 2021
@juliabeliaeva juliabeliaeva deleted the array-initializers branch September 21, 2021 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review This PR is under review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants