diff --git a/yazi-adaptor/src/kitty.rs b/yazi-adaptor/src/kitty.rs index 522a67e5..8b1d3a98 100644 --- a/yazi-adaptor/src/kitty.rs +++ b/yazi-adaptor/src/kitty.rs @@ -1,3 +1,4 @@ +use core::str; use std::{io::{stderr, BufWriter, Write}, path::Path}; use anyhow::Result; @@ -344,7 +345,7 @@ impl Kitty { async fn encode(img: DynamicImage) -> Result> { fn output(raw: &[u8], format: u8, size: (u32, u32)) -> Result> { - let b64: Vec<_> = general_purpose::STANDARD.encode(raw).chars().collect(); + let b64 = general_purpose::STANDARD.encode(raw).into_bytes(); let mut it = b64.chunks(4096).peekable(); let mut buf = Vec::with_capacity(b64.len() + it.len() * 50); @@ -357,7 +358,7 @@ impl Kitty { size.0, size.1, it.peek().is_some() as u8, - first.iter().collect::(), + unsafe { str::from_utf8_unchecked(first) }, ESCAPE, CLOSE )?; @@ -369,7 +370,7 @@ impl Kitty { "{}_Gm={};{}{}\\{}", START, it.peek().is_some() as u8, - chunk.iter().collect::(), + unsafe { str::from_utf8_unchecked(chunk) }, ESCAPE, CLOSE )?; diff --git a/yazi-adaptor/src/kitty_old.rs b/yazi-adaptor/src/kitty_old.rs index 14dd78ee..9f409948 100644 --- a/yazi-adaptor/src/kitty_old.rs +++ b/yazi-adaptor/src/kitty_old.rs @@ -1,3 +1,4 @@ +use core::str; use std::{io::{stderr, Write}, path::Path}; use anyhow::Result; @@ -35,7 +36,7 @@ impl KittyOld { async fn encode(img: DynamicImage) -> Result> { fn output(raw: &[u8], format: u8, size: (u32, u32)) -> Result> { - let b64: Vec<_> = general_purpose::STANDARD.encode(raw).chars().collect(); + let b64 = general_purpose::STANDARD.encode(raw).into_bytes(); let mut it = b64.chunks(4096).peekable(); let mut buf = Vec::with_capacity(b64.len() + it.len() * 50); @@ -48,7 +49,7 @@ impl KittyOld { size.0, size.1, it.peek().is_some() as u8, - first.iter().collect::(), + unsafe { str::from_utf8_unchecked(first) }, ESCAPE, CLOSE )?; @@ -60,7 +61,7 @@ impl KittyOld { "{}_Gm={};{}{}\\{}", START, it.peek().is_some() as u8, - chunk.iter().collect::(), + unsafe { str::from_utf8_unchecked(chunk) }, ESCAPE, CLOSE )?;