fix(liquid_rescale_task.rs): change input_image parameter type from Vec<u8> to &[u8] to avoid unnecessary cloning and improve performance

This commit is contained in:
Timofey Gelazoniya 2023-10-20 14:36:00 +03:00
parent 9c3b4b9608
commit a8d7a39b2f
Signed by: zeldon
GPG Key ID: 047886915281DD2A
1 changed files with 2 additions and 6 deletions

View File

@ -26,7 +26,7 @@ impl LiquidRescaleTask {
}
#[inline]
pub fn liquid_rescale(input_image: Vec<u8>, width: usize, height: usize) -> Result<Buffer> {
pub fn liquid_rescale(input_image: &[u8], width: usize, height: usize) -> Result<Buffer> {
START.call_once(|| {
magick_wand_genesis();
});
@ -52,11 +52,7 @@ impl Task for LiquidRescaleTask {
type JsValue = Buffer;
fn compute(&mut self) -> Result<Self::Output> {
Self::liquid_rescale(
self.input_image.clone().into(),
self.output_width,
self.output_height,
)
Self::liquid_rescale(&self.input_image, self.output_width, self.output_height)
}
fn resolve(&mut self, _env: napi::Env, output: Self::Output) -> Result<Self::JsValue> {