]> code.ossystems Code Review - openembedded-core.git/commitdiff
utils: Reduce the number of calls to the "dirname" command
authorOleksandr Popovych <opopovyc@cisco.com>
Fri, 20 Aug 2021 12:41:43 +0000 (05:41 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 22 Aug 2021 21:21:12 +0000 (22:21 +0100)
utils.bbclass contains create_cmdline_wrapper() function that
creates wrapper script with additional arguments for any passed
"$cmd" command, and uses several calls to "dirname".

Because "dirname" is an external command, in cases of lots of
calls to wrapped "$cmd", each call of "dirname" will incur
significant overhead.

There are three same calls to "dirname": one for saving it`s
output to "realdir" variable, and other two in "exec" command.
So last two "dirname" calls can be replaced with cached value
from "realdir" variable.

Signed-off-by: Oleksandr Popovych <opopovyc@cisco.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/utils.bbclass

index 120bcc64a64439cb929a01bf3d77b648436d214a..072ea1f63c76f72c2410482fd80e98f68626b621 100644 (file)
@@ -214,7 +214,7 @@ create_cmdline_wrapper () {
 #!/bin/bash
 realpath=\`readlink -fn \$0\`
 realdir=\`dirname \$realpath\`
-exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real $cmdoptions "\$@"
+exec -a \$realdir/$cmdname \$realdir/$cmdname.real $cmdoptions "\$@"
 END
        chmod +x $cmd
 }