From 3e3f964e43d6fec8fe0db536a9054567239547c7 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 5 Oct 2017 16:37:30 +0100 Subject: [PATCH] shuilt: re-introduce speedup The previous fix for read_tree_values fixed the issue with sh not supporting arrays, but looping over paths and counting them. Hover each count increment requires spawning a subshell. For a large number of paths, this can eat away any performance benefits of using read_tree_values. Since we only care whether the count is greater than one, detect that and break out of the loop early to re-introduce the performance improvement. --- devlib/bin/scripts/shutils.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in index 007d0a5..49d7407 100755 --- a/devlib/bin/scripts/shutils.in +++ b/devlib/bin/scripts/shutils.in @@ -223,7 +223,10 @@ read_tree_values() { PATHS=$($BUSYBOX find $BASEPATH -follow -maxdepth $MAXDEPTH) i=0 for path in $PATHS; do - i=$(expr $i + 1) + i=$(expr $i + 1) + if [ $i -gt 1 ]; then + break; + fi done if [ $i -gt 1 ]; then $BUSYBOX grep -s '' $PATHS