[bitbake-devel,2/3] utils.py: get_file_layer(): Exit the loop when file is matched

Submitted by Robert Yang on July 30, 2020, 9:23 a.m. | Patch ID: 174900


Message ID 20200730092342.7420-2-liezhi.yang@windriver.com
State New
Headers show

Commit Message

Robert Yang July 30, 2020, 9:23 a.m.
This can make "$ bitbake-layers show-recipes" save about 60% time (14min ->
6min) in my build (more than 3000 recipes)

The command "bitbake-layers show-recipes" calls bb.utils.get_file_layer() with
each recipe, and get_file_layer() compare the file with each item in BBFILES
which makes it very time consuming when there are a lot of recipes and items in
BBFILES. So exit when file is matched, it doesn't make sense to go on the loop
when file is matched.

And use fnmatchcase to replace of fnmatch since the comparison should be

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
 lib/bb/utils.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 50032e50c..03568474d 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1494,9 +1494,10 @@  def get_file_layer(filename, d):
     bbfiles = (d.getVar('BBFILES') or '').split()
     bbfilesmatch = False
     for bbfilesentry in bbfiles:
-        if fnmatch.fnmatch(filename, bbfilesentry):
+        if fnmatch.fnmatchcase(filename, bbfilesentry):
             bbfilesmatch = True
             result = path_to_layer(bbfilesentry)
+            break
     if not bbfilesmatch:
         # Probably a bbclass