[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZvmuVPwaHb1vFCmZ@surfacebook.localdomain>
Date: Sun, 29 Sep 2024 22:45:24 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Qianqiang Liu <qianqiang.liu@....com>
Cc: deller@....de, linux-fbdev@...r.kernel.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fbcon: break earlier in search_fb_in_map and
search_for_mapped_con
Thu, Sep 26, 2024 at 07:59:11PM +0800, Qianqiang Liu kirjoitti:
> Break the for loop immediately upon finding the target, making the
> process more efficient.
You may make it even more effecient (in terms of code readability as I believe
compiler optimizes this anyway to the same):
> int i, retval = 0;
>
> for (i = first_fb_vc; i <= last_fb_vc; i++) {
> - if (con2fb_map[i] == idx)
> + if (con2fb_map[i] == idx) {
> retval = 1;
> + break;
> + }
return 1;
> }
> return retval;
return 0;
> }
...
> int i, retval = 0;
>
> for (i = first_fb_vc; i <= last_fb_vc; i++) {
> - if (con2fb_map[i] != -1)
> + if (con2fb_map[i] != -1) {
> retval = 1;
> + break;
> + }
> }
> return retval;
Ditto.
...
Since it's applied, you can consider a followup.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists