[libcamera-devel] android: camera_device: Replace auto with explicit type
diff mbox series

Message ID 20201212034211.25174-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit bd4894d2596168b3435fb93b9e53dad84b2dcc7e
Headers show
Series
  • [libcamera-devel] android: camera_device: Replace auto with explicit type
Related show

Commit Message

Laurent Pinchart Dec. 12, 2020, 3:42 a.m. UTC
The auto keyword facilitates writing code. It avoids typing out very
long types, which can make the code more readable, but it can also have
a negative impact on readability as it requires the reader (including
reviewers) to look up the type of the variable.

Replace one occurrence of auto with the explicit type where doing so
doesn't require a long type name.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/android/camera_device.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hirokazu Honda Dec. 14, 2020, 1:25 a.m. UTC | #1
Hi Laurent,
Thanks for this patch.

On Sat, Dec 12, 2020 at 12:42 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> The auto keyword facilitates writing code. It avoids typing out very
> long types, which can make the code more readable, but it can also have
> a negative impact on readability as it requires the reader (including
> reviewers) to look up the type of the variable.
>
> Replace one occurrence of auto with the explicit type where doing so
> doesn't require a long type name.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> ---
>  src/android/camera_device.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 38689bdc40b1..79fd02eccdcd 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -199,7 +199,7 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,
>         const auto nv12It = formatToConfigs.find(formats::NV12);
>         if (nv12It != formatToConfigs.end()) {
>                 auto &nv12Configs = nv12It->second;
> -               const auto &nv12Largest = nv12Configs.back();
> +               const Camera3StreamConfig *nv12Largest = nv12Configs.back();
>
>                 /*
>                  * If JPEG will be created from NV12 and the size is larger than
> --
> Regards,
>
> Laurent Pinchart
>
Jacopo Mondi Dec. 14, 2020, 7:48 a.m. UTC | #2
Hi Laurent,

On Sat, Dec 12, 2020 at 05:42:11AM +0200, Laurent Pinchart wrote:
> The auto keyword facilitates writing code. It avoids typing out very
> long types, which can make the code more readable, but it can also have
> a negative impact on readability as it requires the reader (including
> reviewers) to look up the type of the variable.
>
> Replace one occurrence of auto with the explicit type where doing so
> doesn't require a long type name.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/android/camera_device.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 38689bdc40b1..79fd02eccdcd 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -199,7 +199,7 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,
>  	const auto nv12It = formatToConfigs.find(formats::NV12);
>  	if (nv12It != formatToConfigs.end()) {
>  		auto &nv12Configs = nv12It->second;
> -		const auto &nv12Largest = nv12Configs.back();
> +		const Camera3StreamConfig *nv12Largest = nv12Configs.back();
>
>  		/*
>  		 * If JPEG will be created from NV12 and the size is larger than
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 38689bdc40b1..79fd02eccdcd 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -199,7 +199,7 @@  void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,
 	const auto nv12It = formatToConfigs.find(formats::NV12);
 	if (nv12It != formatToConfigs.end()) {
 		auto &nv12Configs = nv12It->second;
-		const auto &nv12Largest = nv12Configs.back();
+		const Camera3StreamConfig *nv12Largest = nv12Configs.back();
 
 		/*
 		 * If JPEG will be created from NV12 and the size is larger than