[v1] ipa: libipa: agc_mean_luminance: Avoid unnecessary copies
diff mbox series

Message ID 20251103140049.413881-1-barnabas.pocze@ideasonboard.com
State Accepted
Headers show
Series
  • [v1] ipa: libipa: agc_mean_luminance: Avoid unnecessary copies
Related show

Commit Message

Barnabás Pőcze Nov. 3, 2025, 2 p.m. UTC
`constraintModes()` and `exposureModeHelpers()` need not return copies of
the internal objects, exposing const references is sufficient, so do that.

Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/libipa/agc_mean_luminance.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dan Scally Nov. 3, 2025, 2:02 p.m. UTC | #1
Hi Barnabas

On 03/11/2025 14:00, Barnabás Pőcze wrote:
> `constraintModes()` and `exposureModeHelpers()` need not return copies of
> the internal objects, exposing const references is sufficient, so do that.
> 
> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Wrong tag :)

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

> ---
>   src/ipa/libipa/agc_mean_luminance.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h
> index d7ec548e3e..e5f164c318 100644
> --- a/src/ipa/libipa/agc_mean_luminance.h
> +++ b/src/ipa/libipa/agc_mean_luminance.h
> @@ -53,12 +53,12 @@ public:
>   	void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
>   		       double minGain, double maxGain, std::vector<AgcConstraint> constraints);
>   
> -	std::map<int32_t, std::vector<AgcConstraint>> constraintModes()
> +	const std::map<int32_t, std::vector<AgcConstraint>> &constraintModes() const
>   	{
>   		return constraintModes_;
>   	}
>   
> -	std::map<int32_t, std::shared_ptr<ExposureModeHelper>> exposureModeHelpers()
> +	const std::map<int32_t, std::shared_ptr<ExposureModeHelper>> &exposureModeHelpers() const
>   	{
>   		return exposureModeHelpers_;
>   	}
Barnabás Pőcze Nov. 3, 2025, 2:34 p.m. UTC | #2
2025. 11. 03. 15:02 keltezéssel, Dan Scally írta:
> Hi Barnabas
> 
> On 03/11/2025 14:00, Barnabás Pőcze wrote:
>> `constraintModes()` and `exposureModeHelpers()` need not return copies of
>> the internal objects, exposing const references is sufficient, so do that.
>>
>> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> 
> Wrong tag :)

Yes :( I have multiple tags pinned in the clipboard manager... I was
wondering how long I can avoid such a mixup. Seems like that day is today.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>


> 
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> 
>> ---
>>   src/ipa/libipa/agc_mean_luminance.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h
>> index d7ec548e3e..e5f164c318 100644
>> --- a/src/ipa/libipa/agc_mean_luminance.h
>> +++ b/src/ipa/libipa/agc_mean_luminance.h
>> @@ -53,12 +53,12 @@ public:
>>       void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
>>                  double minGain, double maxGain, std::vector<AgcConstraint> constraints);
>> -    std::map<int32_t, std::vector<AgcConstraint>> constraintModes()
>> +    const std::map<int32_t, std::vector<AgcConstraint>> &constraintModes() const
>>       {
>>           return constraintModes_;
>>       }
>> -    std::map<int32_t, std::shared_ptr<ExposureModeHelper>> exposureModeHelpers()
>> +    const std::map<int32_t, std::shared_ptr<ExposureModeHelper>> &exposureModeHelpers() const
>>       {
>>           return exposureModeHelpers_;
>>       }
> 
> 
>
Kieran Bingham Nov. 3, 2025, 3:28 p.m. UTC | #3
Quoting Barnabás Pőcze (2025-11-03 14:34:48)
> 2025. 11. 03. 15:02 keltezéssel, Dan Scally írta:
> > Hi Barnabas
> > 
> > On 03/11/2025 14:00, Barnabás Pőcze wrote:
> >> `constraintModes()` and `exposureModeHelpers()` need not return copies of
> >> the internal objects, exposing const references is sufficient, so do that.
> >>
> >> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > 
> > Wrong tag :)
> 
> Yes :( I have multiple tags pinned in the clipboard manager... I was
> wondering how long I can avoid such a mixup. Seems like that day is today.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

:-)


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> 
> 
> > 
> > Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> > 
> >> ---
> >>   src/ipa/libipa/agc_mean_luminance.h | 4 ++--
> >>   1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h
> >> index d7ec548e3e..e5f164c318 100644
> >> --- a/src/ipa/libipa/agc_mean_luminance.h
> >> +++ b/src/ipa/libipa/agc_mean_luminance.h
> >> @@ -53,12 +53,12 @@ public:
> >>       void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
> >>                  double minGain, double maxGain, std::vector<AgcConstraint> constraints);
> >> -    std::map<int32_t, std::vector<AgcConstraint>> constraintModes()
> >> +    const std::map<int32_t, std::vector<AgcConstraint>> &constraintModes() const
> >>       {
> >>           return constraintModes_;
> >>       }
> >> -    std::map<int32_t, std::shared_ptr<ExposureModeHelper>> exposureModeHelpers()
> >> +    const std::map<int32_t, std::shared_ptr<ExposureModeHelper>> &exposureModeHelpers() const
> >>       {
> >>           return exposureModeHelpers_;
> >>       }
> > 
> > 
> > 
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h
index d7ec548e3e..e5f164c318 100644
--- a/src/ipa/libipa/agc_mean_luminance.h
+++ b/src/ipa/libipa/agc_mean_luminance.h
@@ -53,12 +53,12 @@  public:
 	void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,
 		       double minGain, double maxGain, std::vector<AgcConstraint> constraints);
 
-	std::map<int32_t, std::vector<AgcConstraint>> constraintModes()
+	const std::map<int32_t, std::vector<AgcConstraint>> &constraintModes() const
 	{
 		return constraintModes_;
 	}
 
-	std::map<int32_t, std::shared_ptr<ExposureModeHelper>> exposureModeHelpers()
+	const std::map<int32_t, std::shared_ptr<ExposureModeHelper>> &exposureModeHelpers() const
 	{
 		return exposureModeHelpers_;
 	}