[v1,1/2] ipa: libipa: lsc: interpolateComponents(): Avoid copy
diff mbox series

Message ID 20260922155035.235817-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1,1/2] ipa: libipa: lsc: interpolateComponents(): Avoid copy
Related show

Commit Message

Barnabás Pőcze Sept. 22, 2026, 3:50 p.m. UTC
Return the reference directly that is returned by the interpolator.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/libipa/lsc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Sept. 23, 2026, 6:46 a.m. UTC | #1
Quoting Barnabás Pőcze (2026-09-22 16:50:34)
> Return the reference directly that is returned by the interpolator.
> 

The interpolator is generating a new table I expect. Who owns that
memory and keeps it alive to be able to use a reference?

I can see the implementation itself seems to return a reference though:

 src/ipa/libipa/interpolator.h:  const T &getInterpolated(unsigned int key)

Aha, there is storage in the interpolator

        T lastInterpolatedValue_;

So we're returning a reference to that.

In this scenario I think that's fine. No one should be calling
getInterpolated multiple times with different values and expecting to
use both sets. But it might be something to keep in mind, that
successive calls to the interpolator would operate on the same memory.

That's already the case for the interpolator, and this is just improving
the efficiency of the lsc handling, which looks good to me so:

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

> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/ipa/libipa/lsc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/ipa/libipa/lsc.h b/src/ipa/libipa/lsc.h
> index 17d5a4a141..ad378cc6ce 100644
> --- a/src/ipa/libipa/lsc.h
> +++ b/src/ipa/libipa/lsc.h
> @@ -118,7 +118,7 @@ public:
>                 return 0;
>         }
>  
> -       const Components interpolateComponents(unsigned int ct)
> +       const Components &interpolateComponents(unsigned int ct)
>         {
>                 return sets_.getInterpolated(ct);
>         }
> -- 
> 2.55.0
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/lsc.h b/src/ipa/libipa/lsc.h
index 17d5a4a141..ad378cc6ce 100644
--- a/src/ipa/libipa/lsc.h
+++ b/src/ipa/libipa/lsc.h
@@ -118,7 +118,7 @@  public:
 		return 0;
 	}
 
-	const Components interpolateComponents(unsigned int ct)
+	const Components &interpolateComponents(unsigned int ct)
 	{
 		return sets_.getInterpolated(ct);
 	}