bash regex basic simplification (50% time/cpu savings)

This commit is contained in:
2021-07-18 08:57:44 +02:00
parent 8215fde89e
commit d63a340b01
2 changed files with 12 additions and 6 deletions

View File

@@ -29,7 +29,11 @@ function buildtree {
else
if [[ ! -v MATCH[$arg] ]]; then
buildtree "$((prof+1))" "$name" "${RULE[$arg]}"
MATCH[$arg]="(${!name})"
if [[ ${!name} =~ ^.$ ]] ; then
MATCH[$arg]="${!name}"
else
MATCH[$arg]="(${!name})"
fi
fi
res+=${MATCH[$arg]}
fi