Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

perf(rust): apply small allocation and clone micro-optimizations

laurenspriemb04ced8f861b
diff --git a/mobile/apps/photos/rust/src/api/ml_indexing_api.rs b/mobile/apps/photos/rust/src/api/ml_indexing_api.rs
index 0a5f4aed6f..26ac56846a 100644
--- a/mobile/apps/photos/rust/src/api/ml_indexing_api.rs
+++ b/mobile/apps/photos/rust/src/api/ml_indexing_api.rs
@@ -125,7 +125,7 @@ fn analyze_image_rust_inner(req: AnalyzeImageRequest) -> MlResult<AnalyzeImageRe
Some(Vec::new())
} else {
let (aligned, mut face_results) =
- run_face_alignment(req.file_id, &decoded, &detections)?;
+ run_face_alignment(req.file_id, &decoded, detections)?;
runtime::with_runtime_mut(&runtime_config, |runtime| {
run_face_embedding(runtime, &aligned, &mut face_results)
})?;
@@ -148,7 +148,7 @@ fn analyze_image_rust_inner(req: AnalyzeImageRequest) -> MlResult<AnalyzeImageRe
Ok(AnalyzeImageResult {
file_id: req.file_id,
- decoded_image_size: dims.clone(),
+ decoded_image_size: dims,
faces,
clip,
})
diff --git a/mobile/apps/photos/rust/src/ml/face/align.rs b/mobile/apps/photos/rust/src/ml/face/align.rs
index e5b5f46f46..62b0e284bc 100644
--- a/mobile/apps/photos/rust/src/ml/face/align.rs
+++ b/mobile/apps/photos/rust/src/ml/face/align.rs
@@ -34,7 +34,7 @@ struct FaceDetectionAbsolute {
pub fn run_face_alignment(
file_id: i64,
decoded: &DecodedImage,
- detections: &[FaceDetection],
+ detections: Vec<FaceDetection>,
) -> MlResult<(Vec<Vec<f32>>, Vec<FaceResult>)> {
let source = rgb_image_from_decoded(decoded)?;
let mut aligned_face_inputs = Vec::with_capacity(detections.len());
@@ -42,7 +42,7 @@ pub fn run_face_alignment(
for detection in detections {
let absolute_detection = to_absolute_detection(
- detection,
+ &detection,
decoded.dimensions.width,
decoded.dimensions.height,
);
@@ -54,7 +54,7 @@ pub fn run_face_alignment(
aligned_face_inputs.push(normalized);
face_results.push(FaceResult {
- detection: detection.clone(),
+ detection,
blur_value,
alignment,
embedding: Vec::new(),