8000 refactor: remove loop vars that are not updated by Yu-zh · Pull Request #2358 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: remove loop vars that are not updated #2358

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

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions array/fixedarray_sort.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn[T : Compare] timsort(arr : FixedArraySlice[T]) -> Unit {
fn[T : Compare] FixedArraySlice::insertion_sort(
arr : FixedArraySlice[T]
) -> Unit {
for i = 1, len = arr.length(); i < len; i = i + 1 {
for i in 1..<arr.length() {
for j = i; j > 0 && arr[j] < arr[j - 1]; j = j - 1 {
arr.swap(j, j - 1)
}
Expand Down Expand Up @@ -538,7 +538,7 @@ test "stable_sort_complex" {
let total_len = run_lens.fold(init=0, (acc, x) => acc + x)
let arr = FixedArray::make(total_len, 0)
let mut index = 0
for i = 0, len = run_lens.length(); i < len; i = i + 1 {
for i in 0..<run_lens.length() {
for j in 0..<run_lens[i] {
arr[index] = j
index += 1
Expand Down
2 changes: 1 addition & 1 deletion builtin/iter_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ test "concat" {
test "collect" {
let arr = ['1', '2', '3', '4', '5']
let iter = Iter::new(fn(yield_) {
for i = 0, len = arr.length(); i < len; i = i + 1 {
for i in 0..<arr.length() {
yield_(arr[i]) |> ignore
}
IterContinue
Expand Down
4 changes: 2 additions & 2 deletions bytes/bytes.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn to_array(self : Bytes) -> Array[Byte] {
/// ```
pub fn iter(self : Bytes) -> Iter[Byte] {
Iter::new(fn(yield_) {
for i = 0, len = self.length(); i < len; i = i + 1 {
for i in 0..<self.length() {
if yield_(self[i]) == IterEnd {
break IterEnd
}
Expand All @@ -239,7 +239,7 @@ pub fn iter(self : Bytes) -> Iter[Byte] {
/// inspect(keys, content="[0, 1, 2, 3, 4]")
pub fn iter2(self : Bytes) -> Iter2[Int, Byte] {
Iter2::new(fn(yield_) {
for i = 0, len = self.length(); i < len; i = i + 1 {
for i in 0..<self.length() {
if yield_(i, self[i]) == IterEnd {
break IterEnd
}
Expand Down
0