[vlc-devel] [PATCH] display: avoid using memset in vout_display_PlacePicture()
Steve Lhomme
robux4 at ycbcr.xyz
Fri Aug 21 13:49:24 CEST 2020
On 2020-08-21 13:46, Rémi Denis-Courmont wrote:
> Hi,
>
> First, that's a rather dubious optimization. Compilers know how to
> inline a fixed-size memset(), and you end up with one more branch with
> this patch.
OK. I'm surprised a compiler could optimize a memset but not a set to {
0 } of a structure.
> It doesn't make the code any clearer either.
If you end up changing the type of *place you may not notice. But it's
really splitting hairs.
> Le 21 août 2020 10:19:24 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a
> écrit :
>
> It's only needed when the display has no dimension yet. The rest of the time
> we fill all (4) fields of the vout_display_place_t structure.
> ------------------------------------------------------------------------
> src/video_output/display.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/video_output/display.c b/src/video_output/display.c
> index 8fd444168d0..84284e8f41d 100644
> --- a/src/video_output/display.c
> +++ b/src/video_output/display.c
> @@ -150,9 +150,11 @@ void vout_display_PlacePicture(vout_display_place_t *place,
> assert(cfg->window_props.width == 0 && cfg->window_props.height == 0);
>
> /* */
> - memset(place, 0, sizeof(*place));
> if (cfg->display.width == 0 || cfg->display.height == 0)
> + {
> + *place = (vout_display_place_t) { 0 };
> return;
> + }
>
> /* */
> unsigned display_width;
>
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser
> ma brièveté.
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list