From 7bf4bec257dffb633d818fb1a7ade6b899ec79a5 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Thu, 15 Dec 2022 22:50:36 -0500 Subject: camera: Use pre-allocated vector for camera data And avoid an unnecessary copy --- src/input_common/drivers/camera.cpp | 2 +- src/input_common/drivers/camera.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/input_common') diff --git a/src/input_common/drivers/camera.cpp b/src/input_common/drivers/camera.cpp index dceea67e0..fad9177dc 100644 --- a/src/input_common/drivers/camera.cpp +++ b/src/input_common/drivers/camera.cpp @@ -17,7 +17,7 @@ Camera::Camera(std::string input_engine_) : InputEngine(std::move(input_engine_) PreSetController(identifier); } -void Camera::SetCameraData(std::size_t width, std::size_t height, std::vector data) { +void Camera::SetCameraData(std::size_t width, std::size_t height, std::span data) { const std::size_t desired_width = getImageWidth(); const std::size_t desired_height = getImageHeight(); status.data.resize(desired_width * desired_height); diff --git a/src/input_common/drivers/camera.h b/src/input_common/drivers/camera.h index b8a7c75e5..38fb1ae4c 100644 --- a/src/input_common/drivers/camera.h +++ b/src/input_common/drivers/camera.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "input_common/input_engine.h" namespace InputCommon { @@ -15,7 +17,7 @@ class Camera final : public InputEngine { public: explicit Camera(std::string input_engine_); - void SetCameraData(std::size_t width, std::size_t height, std::vector data); + void SetCameraData(std::size_t width, std::size_t height, std::span data); std::size_t getImageWidth() const; std::size_t getImageHeight() const; -- cgit v1.2.3