mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 13:00:36 -05:00
perf: return the value not a struct but a tuple
This commit is contained in:
parent
fb6b87d656
commit
3beb65b9f0
2 changed files with 5 additions and 18 deletions
|
@ -271,9 +271,9 @@ function createImageBitmap(
|
||||||
imageBitmapSource,
|
imageBitmapSource,
|
||||||
mimeType,
|
mimeType,
|
||||||
);
|
);
|
||||||
imageBitmap[_bitmapData] = processedImage.data;
|
imageBitmap[_bitmapData] = processedImage[0];
|
||||||
imageBitmap[_width] = processedImage.width;
|
imageBitmap[_width] = processedImage[1];
|
||||||
imageBitmap[_height] = processedImage.height;
|
imageBitmap[_height] = processedImage[2];
|
||||||
return imageBitmap;
|
return imageBitmap;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ use image::DynamicImage;
|
||||||
use image::ImageError;
|
use image::ImageError;
|
||||||
use image::RgbaImage;
|
use image::RgbaImage;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use crate::error::image_error_message;
|
use crate::error::image_error_message;
|
||||||
use crate::error::DOMExceptionInvalidStateError;
|
use crate::error::DOMExceptionInvalidStateError;
|
||||||
|
@ -71,14 +70,6 @@ enum ResizeQuality {
|
||||||
High,
|
High,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
struct OpCreateImageBitmapReturn {
|
|
||||||
data: ToJsBuffer,
|
|
||||||
width: u32,
|
|
||||||
height: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
type DecodeBitmapDataReturn = (DynamicImage, u32, u32, Option<Vec<u8>>);
|
type DecodeBitmapDataReturn = (DynamicImage, u32, u32, Option<Vec<u8>>);
|
||||||
|
|
||||||
fn decode_bitmap_data(
|
fn decode_bitmap_data(
|
||||||
|
@ -282,7 +273,7 @@ pub(super) fn op_create_image_bitmap(
|
||||||
#[serde] resize_quality: ResizeQuality,
|
#[serde] resize_quality: ResizeQuality,
|
||||||
#[serde] image_bitmap_source: ImageBitmapSource,
|
#[serde] image_bitmap_source: ImageBitmapSource,
|
||||||
#[string] mime_type: &str,
|
#[string] mime_type: &str,
|
||||||
) -> Result<OpCreateImageBitmapReturn, AnyError> {
|
) -> Result<(ToJsBuffer, u32, u32), AnyError> {
|
||||||
// 6. Switch on image:
|
// 6. Switch on image:
|
||||||
let (image, width, height, icc_profile) =
|
let (image, width, height, icc_profile) =
|
||||||
decode_bitmap_data(&buf, width, height, &image_bitmap_source, mime_type)?;
|
decode_bitmap_data(&buf, width, height, &image_bitmap_source, mime_type)?;
|
||||||
|
@ -381,9 +372,5 @@ pub(super) fn op_create_image_bitmap(
|
||||||
let image =
|
let image =
|
||||||
apply_premultiply_alpha(image, &image_bitmap_source, &premultiply_alpha)?;
|
apply_premultiply_alpha(image, &image_bitmap_source, &premultiply_alpha)?;
|
||||||
|
|
||||||
Ok(OpCreateImageBitmapReturn {
|
Ok((image.into_bytes().into(), output_width, output_height))
|
||||||
data: image.into_bytes().into(),
|
|
||||||
width: output_width,
|
|
||||||
height: output_height,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue