Use Vec::with_capacity (#891)

Co-authored-by: Matthew Martin <phy1729@Matthews-Mac-mini.local>
This commit is contained in:
Matthew Martin
2026-02-17 11:55:34 -06:00
committed by GitHub
parent 9b6c4cee0b
commit 062db87572
4 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -102,7 +102,7 @@ pub trait GenericFramebuffer: Send + 'static {
resized_img = img;
}
let img_rgba8 = resized_img.as_rgba8().unwrap();
let mut buf = Vec::new();
let mut buf = Vec::with_capacity((height * width).try_into().unwrap());
for y in 0..height {
for x in 0..width {
let px = img_rgba8.get_pixel(x, y);
@@ -145,7 +145,7 @@ pub trait GenericFramebuffer: Send + 'static {
async fn draw_patterned_line(&mut self, color: Color, height: u32, pattern: LinePattern) {
let width = self.dimensions().width;
let mut buffer = Vec::new();
let mut buffer = Vec::with_capacity((height * width).try_into().unwrap());
for _row in 0..height {
for col in 0..width {