Use shell pattern matching and parameter expansion to skip backup
modules and derive module names without invoking sed, basename, or cut
during initramfs module loading.

On QEMU, backup filtering decreased from 104.529 ms to 3.731 ms,
and module name parsing decreased from 115.657 ms to 4.071 ms.
Together, these stages decreased from 220.186 ms to 7.802 ms.

Tested with dash and BusyBox sh syntax checks and QEMU.

AI-Generated: OpenAI Codex
Signed-off-by: Wenwen Fu <[email protected]>
---
 .../initrdscripts/initramfs-framework/init           | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init 
b/meta/recipes-core/initrdscripts/initramfs-framework/init
index e560d25d53..e2da3511b8 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/init
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
@@ -152,11 +152,15 @@ mkdir $ROOTFS_DIR
 # Load and run modules
 for m in $MODULES_DIR/*; do
        # Skip backup files
-       if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then
-               continue
-       fi
+       case "$m" in
+               *~)
+                       continue
+                       ;;
+       esac
 
-       module=`basename $m | cut -d'-' -f 2`
+       module=${m##*/}
+       module=${module#*-}
+       module=${module%%-*}
        debug "Loading module $module"
 
        # pre hooks
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#245713): 
https://lists.openembedded.org/g/openembedded-core/message/245713
Mute This Topic: https://lists.openembedded.org/mt/121224837/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to