Micro optimization. Win is now a real 50% cpu/time vs 1st version

This commit is contained in:
2021-07-18 09:40:31 +02:00
parent df5836de1e
commit e674488a17

View File

@@ -21,7 +21,7 @@ function buildtree {
local name="var_$prof" # local var name, w/ depth local name="var_$prof" # local var name, w/ depth
eval "local $name" # ... declared here eval "local $name" # ... declared here
shift 2 shift 2
local args=$* res="" arg local args=$* res="" arg tmp
for arg in $args; do for arg in $args; do
if [[ -z "${arg/[|ab]}" ]]; then if [[ -z "${arg/[|ab]}" ]]; then
@@ -29,11 +29,9 @@ function buildtree {
else else
if [[ ! -v MATCH[$arg] ]]; then if [[ ! -v MATCH[$arg] ]]; then
buildtree "$((prof+1))" "$name" "${RULE[$arg]}" buildtree "$((prof+1))" "$name" "${RULE[$arg]}"
if [[ ${!name} =~ ^.$ ]] ; then tmp="${!name}"
MATCH[$arg]="${!name}" [[ ! "$tmp" =~ ^.$ ]] && tmp="($tmp)"
else MATCH[$arg]="$tmp"
MATCH[$arg]="(${!name})"
fi
fi fi
res+=${MATCH[$arg]} res+=${MATCH[$arg]}
fi fi