From 0a346b8372140b56bf65a6df1c00e2cd6c6cdf86 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 17 Dec 2022 18:01:51 +0100 Subject: small optimizations and info binary --- evc/src/frame.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'evc/src/frame.rs') diff --git a/evc/src/frame.rs b/evc/src/frame.rs index 81fdf3b..78d0e73 100644 --- a/evc/src/frame.rs +++ b/evc/src/frame.rs @@ -63,11 +63,8 @@ impl Index> for Frame { type Output = Pixel; #[inline] fn index(&self, Vec2 { x, y }: Vec2) -> &Self::Output { - if x >= 0 && y >= 0 && x < self.size.x && y < self.size.y { - &self.buffer[(x + y * self.size.x) as usize] - } else { - &Pixel::BLACK - } + &self.buffer + [(x.clamp(0, self.size.x - 1) + y.clamp(0, self.size.y - 1) * self.size.x) as usize] } } impl IndexMut> for Frame { -- cgit v1.2.3-70-g09d2