On 03/02/26, Pierrick Bouvier wrote:
> target_arch() function will reparse target_name() every time if it was
> not set to a proper SYS_EMU_TARGET_* value (when using
> target-info-stub.c), which is not efficient.
> 
> Since we want to preserve the constness of TargetInfo but C doesn't give
> us flexible compile time expressions, we simply set target_arch using a
> static constructor once instead.
> 
> This was found when doing changes to virtio_access_is_big_endian()
> function, having an overhead of 50% after switching to runtime checks.
> With this, overhead left is around 3%, due to indirect function
> calls.
> 
> Signed-off-by: Pierrick Bouvier <[email protected]>
> ---
>  target-info-stub.c | 11 ++++++++++-
>  target-info.c      |  9 +--------
>  2 files changed, 11 insertions(+), 9 deletions(-)

Good find!

Reviewed-by: Anton Johansson <[email protected]>

Reply via email to