From 154ea8c8e421f30768d83018a978f894539fdbdd Mon Sep 17 00:00:00 2001 From: rami3l Date: Thu, 26 Dec 2024 12:06:43 +0800 Subject: [PATCH] perf(deque): use `@deque.rev_iter[2]()` for `@deque.rev_each[i]()` --- deque/deque.mbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deque/deque.mbt b/deque/deque.mbt index 140ad339f..3ab74a07a 100644 --- a/deque/deque.mbt +++ b/deque/deque.mbt @@ -431,8 +431,8 @@ pub fn eachi[A](self : T[A], f : (Int, A) -> Unit) -> Unit { /// assert_eq!(sum, 15) /// ``` pub fn rev_each[A](self : T[A], f : (A) -> Unit) -> Unit { - for i = self.length() - 1; i >= 0; i = i - 1 { - f(self[i]) + for v in self.rev_iter() { + f(v) } } @@ -447,8 +447,8 @@ pub fn rev_each[A](self : T[A], f : (A) -> Unit) -> Unit { /// assert_eq!(idx_sum, 10) /// ``` pub fn rev_eachi[A](self : T[A], f : (Int, A) -> Unit) -> Unit { - for i = 0; i < self.len; i = i + 1 { - f(i, self[self.len - i - 1]) + for i, v in self.rev_iter2() { + f(i, v) } }