From 3de9e4415ebfde7a56e0a5a9f279c537c6efa0e1 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 24 Dec 2024 10:33:03 +0800 Subject: [PATCH] perf(deque): use `@deque.iter[2]()` for `@deque.each[i]()` --- deque/deque.mbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deque/deque.mbt b/deque/deque.mbt index b8272b501..8b2e7f629 100644 --- a/deque/deque.mbt +++ b/deque/deque.mbt @@ -346,8 +346,8 @@ pub fn op_equal[A : Eq](self : T[A], other : T[A]) -> Bool { /// assert_eq!(sum, 15) /// ``` pub fn each[A](self : T[A], f : (A) -> Unit) -> Unit { - for i = 0; i < self.length(); i = i + 1 { - f(self[i]) + for v in self { + f(v) } } @@ -362,8 +362,8 @@ pub fn each[A](self : T[A], f : (A) -> Unit) -> Unit { /// assert_eq!(idx_sum, 10) /// ``` pub fn eachi[A](self : T[A], f : (Int, A) -> Unit) -> Unit { - for i = 0; i < self.length(); i = i + 1 { - f(i, self[i]) + for i, v in self { + f(i, v) } }