Skip to content

Commit

Permalink
perf(deque): use @deque.rev_iter[2]() for @deque.rev_each[i]()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Dec 26, 2024
1 parent 703858a commit 154ea8c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions deque/deque.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down

0 comments on commit 154ea8c

Please sign in to comment.