]> www.infradead.org Git - users/hch/block.git/commitdiff
fbcon: break earlier in search_fb_in_map and search_for_mapped_con
authorQianqiang Liu <qianqiang.liu@163.com>
Thu, 26 Sep 2024 11:59:11 +0000 (19:59 +0800)
committerHelge Deller <deller@gmx.de>
Thu, 26 Sep 2024 16:25:12 +0000 (18:25 +0200)
Break the for loop immediately upon finding the target, making the
process more efficient.

Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/core/fbcon.c

index d9abae2516d8407315eddb24d492a98f06311d65..e8b4e8c119b5ce640b32fcfb80bbc545711da80f 100644 (file)
@@ -512,8 +512,10 @@ static int search_fb_in_map(int idx)
        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 retval;
 }
@@ -523,8 +525,10 @@ static int search_for_mapped_con(void)
        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;
 }