Optimize the regular expression so that the variable expansion part always ends up in group 1, and the trailer after the variable is discarded in the same match. Do not use re.sub to remove braces, and do not bother building the expanded command, just adjust the estimated length on the fly. functools.reduce is extremely slow, so I am keeping ' '.join(chunk). On a QEMU build the time spend in the function goes from 1.072s to 0.757s.pull/7607/head
parent
fcf9746232
commit
b14601da7b
1 changed files with 12 additions and 10 deletions
Loading…
Reference in new issue