Skip to content

Commit

Permalink
Optimize ByteArray.iter a little bit
Browse files Browse the repository at this point in the history
ByteArray.get performs a bounds check, which is redundant in
ByteArray.iter. Since it will likely take a while before the compiler is
able to remove bounds checking where possible, we'll need to do this by
hand in the mean time.

Changelog: performance
  • Loading branch information
yorickpeterse committed Oct 24, 2023
1 parent de6a4de commit 07632a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion std/src/std/byte_array.inko
Expand Up @@ -319,7 +319,11 @@ class builtin ByteArray {
let max = size

Stream.new fn move {
if idx < max { Option.Some(get(idx := idx + 1)) } else { Option.None }
if idx < max {
Option.Some(inko_byte_array_get(self, idx := idx + 1))
} else {
Option.None
}
}
}

Expand Down

0 comments on commit 07632a3

Please sign in to comment.