vsed: reduce number of digest cmd call
For a vsed call to `nf' files and `nr' regex, the old code will make `2 * nf * nr' digest calls. the new code will make `nf * (nr + 1)' digest calls. Refereance: https://github.com/void-linux/void-packages/issues/11238
This commit is contained in:
parent
9374b6938e
commit
bbce69f036
1 changed files with 5 additions and 4 deletions
|
@ -44,11 +44,11 @@ vsed() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
for rx in "${regexes[@]}"; do
|
||||
for f in "${files[@]}"; do
|
||||
olddigest="$($XBPS_DIGEST_CMD "$f")"
|
||||
olddigest="${olddigest%% *}"
|
||||
for f in "${files[@]}"; do
|
||||
olddigest="$($XBPS_DIGEST_CMD "$f")"
|
||||
olddigest="${olddigest%% *}"
|
||||
|
||||
for rx in "${regexes[@]}"; do
|
||||
sed -i "$f" -e "$rx" || {
|
||||
msg_red "$pkgver: vsed: sed call failed with regex \"$rx\" on file \"$f\"\n"
|
||||
return 1
|
||||
|
@ -60,6 +60,7 @@ vsed() {
|
|||
if [ "$olddigest" = "$newdigest" ]; then
|
||||
msg_warn "$pkgver: vsed: regex \"$rx\" didn't change file \"$f\"\n"
|
||||
fi
|
||||
olddigest="${newdigest}"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue