Skip to content

Commit

Permalink
perf(deque): use @deque.iter[2]() for @deque.each[i]()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l authored and bobzhang committed Dec 25, 2024
1 parent 9cb4c07 commit 3de9e44
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 @@ -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)
}
}

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

Expand Down

0 comments on commit 3de9e44

Please sign in to comment.